massive change to stop the editor fromknowing about nsIPresShell or nsIDocument
git-svn-id: svn://10.0.0.236/trunk@67485 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
6ed5ffdd71
commit
aacbb20c68
@ -67,7 +67,7 @@ NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData *aElement,
|
||||
PRUint32 aReplaceLength,
|
||||
nsIPrivateTextRangeList *aTextRangeList,
|
||||
const nsString &aStringToInsert,
|
||||
nsWeakPtr aPresShellWeak)
|
||||
nsWeakPtr aSelConWeak)
|
||||
{
|
||||
NS_ASSERTION(aElement, "illegal value- null ptr- aElement");
|
||||
NS_ASSERTION(aTextRangeList, "illegal value- null ptr - aTextRangeList");
|
||||
@ -77,7 +77,7 @@ NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData *aElement,
|
||||
mOffset = aOffset;
|
||||
mReplaceLength = aReplaceLength;
|
||||
mStringToInsert = aStringToInsert;
|
||||
mPresShellWeak = aPresShellWeak;
|
||||
mSelConWeak = aSelConWeak;
|
||||
mRangeList = do_QueryInterface(aTextRangeList);
|
||||
mFixed = PR_FALSE;
|
||||
return NS_OK;
|
||||
@ -90,8 +90,8 @@ NS_IMETHODIMP IMETextTxn::Do(void)
|
||||
printf("Do IME Text element = %p replace = %d len = %d\n", mElement.get(), mReplaceLength, mStringToInsert.Length());
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
|
||||
if (!ps) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mSelConWeak);
|
||||
if (!selCon) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// advance caret: This requires the presentation shell to get the selection.
|
||||
nsresult result = NS_OK;
|
||||
@ -113,7 +113,7 @@ NS_IMETHODIMP IMETextTxn::Undo(void)
|
||||
printf("Undo IME Text element = %p\n", mElement.get());
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mPresShellWeak);
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mSelConWeak);
|
||||
if (!selCon) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult result;
|
||||
@ -309,7 +309,7 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void)
|
||||
//
|
||||
// run through the text range list, if any
|
||||
//
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mPresShellWeak);
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mSelConWeak);
|
||||
if (!selCon) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
result = mRangeList->GetLength(&textRangeListLength);
|
||||
|
||||
@ -59,14 +59,14 @@ public:
|
||||
* @param aOffset the location in aElement to do the insertion
|
||||
* @param aReplaceLength the length of text to replace (0= no replacement)
|
||||
* @param aString the new text to insert
|
||||
* @param aPresShell used to get and set the selection
|
||||
* @param aSelCon used to get and set the selection
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDOMCharacterData *aElement,
|
||||
PRUint32 aOffset,
|
||||
PRUint32 aReplaceLength,
|
||||
nsIPrivateTextRangeList* aTextRangeList,
|
||||
const nsString& aString,
|
||||
nsWeakPtr aPresShell);
|
||||
nsWeakPtr aSelCon);
|
||||
|
||||
private:
|
||||
|
||||
@ -120,8 +120,8 @@ protected:
|
||||
/** the range list **/
|
||||
nsCOMPtr<nsIPrivateTextRangeList> mRangeList;
|
||||
|
||||
/** the presentation shell, which we'll need to get the selection */
|
||||
nsWeakPtr mPresShellWeak; // use a weak reference
|
||||
/** the selection controller, which we'll need to get the selection */
|
||||
nsWeakPtr mSelConWeak; // use a weak reference
|
||||
|
||||
PRBool mFixed;
|
||||
|
||||
|
||||
@ -24,7 +24,6 @@
|
||||
#include "nsEditor.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "EditAggregateTxn.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMSelectionIID, NS_IDOMSELECTION_IID);
|
||||
|
||||
@ -825,8 +825,9 @@ NS_IMPL_QUERY_INTERFACE3(nsEditor, nsIEditor, nsIEditorIMESupport, nsISupportsWe
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell, PRUint32 aFlags)
|
||||
nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell, nsISelectionController *aSelCon, PRUint32 aFlags)
|
||||
{
|
||||
NS_PRECONDITION(nsnull!=aDoc && nsnull!=aPresShell, "bad arg");
|
||||
if ((nsnull==aDoc) || (nsnull==aPresShell))
|
||||
@ -835,6 +836,7 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell, PRUint32 aFlags)
|
||||
mFlags = aFlags;
|
||||
mDocWeak = getter_AddRefs( NS_GetWeakReference(aDoc) ); // weak reference to doc
|
||||
mPresShellWeak = getter_AddRefs( NS_GetWeakReference(aPresShell) ); // weak reference to pres shell
|
||||
mSelConWeak = getter_AddRefs( NS_GetWeakReference(aSelCon) ); // weak reference to selectioncontroller
|
||||
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
|
||||
if (!ps) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
@ -914,7 +916,8 @@ nsEditor::GetDocument(nsIDOMDocument **aDoc)
|
||||
if (!mDocWeak) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsCOMPtr<nsIDOMDocument> doc = do_QueryReferent(mDocWeak);
|
||||
if (!doc) return NS_ERROR_NOT_INITIALIZED;
|
||||
return doc->QueryInterface(NS_GET_IID(nsIDOMDocument), (void **)aDoc);
|
||||
NS_ADDREF(*aDoc = doc);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -939,9 +942,9 @@ nsEditor::GetSelectionController(nsISelectionController **aSel)
|
||||
if (!aSel)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aSel = nsnull; // init out param
|
||||
NS_PRECONDITION(mPresShellWeak, "bad state, null mPresShellWeak");
|
||||
if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mPresShellWeak);
|
||||
NS_PRECONDITION(mSelConWeak, "bad state, null mSelConWeak");
|
||||
if (!mSelConWeak) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mSelConWeak);
|
||||
if (!selCon) return NS_ERROR_NOT_INITIALIZED;
|
||||
NS_ADDREF(*aSel = selCon);
|
||||
return NS_OK;
|
||||
@ -955,8 +958,8 @@ nsEditor::GetSelection(nsIDOMSelection **aSelection)
|
||||
if (!aSelection)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aSelection = nsnull;
|
||||
if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsCOMPtr<nsISelectionController> selcon = do_QueryReferent(mPresShellWeak);
|
||||
if (!mSelConWeak) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsCOMPtr<nsISelectionController> selcon = do_QueryReferent(mSelConWeak);
|
||||
if (!selcon) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsresult result = selcon->GetSelection(nsISelectionController::SELECTION_NORMAL, aSelection); // does an addref
|
||||
return result;
|
||||
@ -4928,7 +4931,7 @@ nsresult nsEditor::EndUpdateViewBatch()
|
||||
mViewManager->EndUpdateViewBatch(NS_VMREFRESH_IMMEDIATE);
|
||||
#endif
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
nsresult rv = GetPresShell(getter_AddRefs(presShell));
|
||||
rv = GetPresShell(getter_AddRefs(presShell));
|
||||
if (NS_SUCCEEDED(rv) && presShell)
|
||||
presShell->EndReflowBatching(PR_TRUE);
|
||||
}
|
||||
@ -5197,7 +5200,7 @@ nsEditor::CreateTxnForIMEText(const nsString & aStringToInsert,
|
||||
|
||||
result = TransactionFactory::GetNewTransaction(IMETextTxn::GetCID(), (EditTxn **)aTxn);
|
||||
if (nsnull!=*aTxn) {
|
||||
result = (*aTxn)->Init(mIMETextNode,mIMETextOffset,mIMEBufferLength,mIMETextRangeList,aStringToInsert,mPresShellWeak);
|
||||
result = (*aTxn)->Init(mIMETextNode,mIMETextOffset,mIMEBufferLength,mIMETextRangeList,aStringToInsert,mSelConWeak);
|
||||
}
|
||||
else {
|
||||
result = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
@ -70,6 +70,8 @@ class IMETextTxn;
|
||||
class AddStyleSheetTxn;
|
||||
class RemoveStyleSheetTxn;
|
||||
class nsFileSpec;
|
||||
class nsISelectionController;
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* class for recording selection info. stores selection as collection of
|
||||
@ -187,7 +189,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/* ------------ nsIEditor methods -------------- */
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, PRUint32 aFlags);
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsISelectionController *aSelCon, PRUint32 aFlags);
|
||||
NS_IMETHOD PostCreate();
|
||||
NS_IMETHOD GetFlags(PRUint32 *aFlags) = 0;
|
||||
NS_IMETHOD SetFlags(PRUint32 aFlags) = 0;
|
||||
@ -725,6 +727,7 @@ protected:
|
||||
PRUint32 mFlags; // behavior flags. See nsIHTMLEditor.h for the flags we use.
|
||||
|
||||
nsWeakPtr mPresShellWeak; // weak reference to the nsIPresShell
|
||||
nsWeakPtr mSelConWeak; // weak reference to the nsISelectionController
|
||||
nsIViewManager *mViewManager;
|
||||
PRInt32 mUpdateCount;
|
||||
nsCOMPtr<nsITransactionManager> mTxnMgr;
|
||||
|
||||
@ -477,12 +477,6 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||
if (!editor) { return NS_OK; }
|
||||
|
||||
|
||||
// get the document
|
||||
nsCOMPtr<nsIDOMDocument>domDoc;
|
||||
editor->GetDocument(getter_AddRefs(domDoc));
|
||||
if (!domDoc) { return NS_OK; }
|
||||
nsCOMPtr<nsIDocument>doc = do_QueryInterface(domDoc);
|
||||
if (!doc) { return NS_OK; }
|
||||
|
||||
PRUint16 button = 0;
|
||||
mouseEvent->GetButton(&button);
|
||||
@ -1083,16 +1077,7 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
|
||||
selCon->SetCaretEnabled(PR_TRUE);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMDocument>domDoc;
|
||||
editor->GetDocument(getter_AddRefs(domDoc));
|
||||
if (domDoc)
|
||||
{
|
||||
nsCOMPtr<nsIDocument>doc = do_QueryInterface(domDoc);
|
||||
if (doc)
|
||||
{
|
||||
doc->SetDisplaySelection(nsIDocument::SELECTION_ON);
|
||||
}
|
||||
}
|
||||
selCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
|
||||
#ifdef USE_HACK_REPAINT
|
||||
// begin hack repaint
|
||||
nsCOMPtr<nsIViewManager> viewmgr;
|
||||
@ -1131,17 +1116,7 @@ nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent)
|
||||
if (selCon)
|
||||
{
|
||||
selCon->SetCaretEnabled(PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIDOMDocument>domDoc;
|
||||
editor->GetDocument(getter_AddRefs(domDoc));
|
||||
if (domDoc)
|
||||
{
|
||||
nsCOMPtr<nsIDocument>doc = do_QueryInterface(domDoc);
|
||||
if (doc)
|
||||
{
|
||||
doc->SetDisplaySelection(nsIDocument::SELECTION_DISABLED);
|
||||
}
|
||||
}
|
||||
selCon->SetDisplaySelection(nsISelectionController::SELECTION_DISABLED);
|
||||
#ifdef USE_HACK_REPAINT
|
||||
// begin hack repaint
|
||||
nsCOMPtr<nsIViewManager> viewmgr;
|
||||
|
||||
@ -602,22 +602,23 @@ nsEditorShell::InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShell)
|
||||
err = nsComponentManager::CreateInstance(kHTMLEditorCID, nsnull, NS_GET_IID(nsIEditor), getter_AddRefs(editor));
|
||||
if(!editor)
|
||||
err = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(aPresShell);
|
||||
|
||||
if (NS_SUCCEEDED(err))
|
||||
{
|
||||
if (mEditorTypeString.EqualsWithConversion("text"))
|
||||
{
|
||||
err = editor->Init(aDoc, aPresShell, nsIHTMLEditor::eEditorPlaintextMask);
|
||||
err = editor->Init(aDoc, aPresShell, selCon, nsIHTMLEditor::eEditorPlaintextMask);
|
||||
mEditorType = ePlainTextEditorType;
|
||||
}
|
||||
else if (mEditorTypeString.EqualsWithConversion("html") || mEditorTypeString.IsEmpty()) // empty string default to HTML editor
|
||||
{
|
||||
err = editor->Init(aDoc, aPresShell, 0);
|
||||
err = editor->Init(aDoc, aPresShell, selCon, 0);
|
||||
mEditorType = eHTMLTextEditorType;
|
||||
}
|
||||
else if (mEditorTypeString.EqualsWithConversion("htmlmail")) // HTML editor with special mail rules
|
||||
{
|
||||
err = editor->Init(aDoc, aPresShell, nsIHTMLEditor::eEditorMailMask);
|
||||
err = editor->Init(aDoc, aPresShell, selCon, nsIHTMLEditor::eEditorMailMask);
|
||||
mEditorType = eHTMLTextEditorType;
|
||||
}
|
||||
else
|
||||
|
||||
@ -380,7 +380,7 @@ NS_IMETHODIMP nsHTMLEditor::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::Init(nsIDOMDocument *aDoc,
|
||||
nsIPresShell *aPresShell, PRUint32 aFlags)
|
||||
nsIPresShell *aPresShell, nsISelectionController *aSelCon, PRUint32 aFlags)
|
||||
{
|
||||
NS_PRECONDITION(aDoc && aPresShell, "bad arg");
|
||||
if (!aDoc || !aPresShell)
|
||||
@ -388,7 +388,7 @@ NS_IMETHODIMP nsHTMLEditor::Init(nsIDOMDocument *aDoc,
|
||||
|
||||
nsresult result = NS_ERROR_NULL_POINTER;
|
||||
// Init the base editor
|
||||
result = nsEditor::Init(aDoc, aPresShell, aFlags);
|
||||
result = nsEditor::Init(aDoc, aPresShell, aSelCon, aFlags);
|
||||
if (NS_FAILED(result)) { return result; }
|
||||
|
||||
nsCOMPtr<nsIDOMElement> bodyElement;
|
||||
|
||||
@ -242,7 +242,7 @@ public:
|
||||
/* ------------ Overrides of nsEditor interface methods -------------- */
|
||||
|
||||
/** prepare the editor for use */
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, PRUint32 aFlags);
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsISelectionController *aSelCon, PRUint32 aFlags);
|
||||
|
||||
NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet);
|
||||
|
||||
|
||||
@ -22,7 +22,6 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
||||
@ -602,22 +602,23 @@ nsEditorShell::InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShell)
|
||||
err = nsComponentManager::CreateInstance(kHTMLEditorCID, nsnull, NS_GET_IID(nsIEditor), getter_AddRefs(editor));
|
||||
if(!editor)
|
||||
err = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(aPresShell);
|
||||
|
||||
if (NS_SUCCEEDED(err))
|
||||
{
|
||||
if (mEditorTypeString.EqualsWithConversion("text"))
|
||||
{
|
||||
err = editor->Init(aDoc, aPresShell, nsIHTMLEditor::eEditorPlaintextMask);
|
||||
err = editor->Init(aDoc, aPresShell, selCon, nsIHTMLEditor::eEditorPlaintextMask);
|
||||
mEditorType = ePlainTextEditorType;
|
||||
}
|
||||
else if (mEditorTypeString.EqualsWithConversion("html") || mEditorTypeString.IsEmpty()) // empty string default to HTML editor
|
||||
{
|
||||
err = editor->Init(aDoc, aPresShell, 0);
|
||||
err = editor->Init(aDoc, aPresShell, selCon, 0);
|
||||
mEditorType = eHTMLTextEditorType;
|
||||
}
|
||||
else if (mEditorTypeString.EqualsWithConversion("htmlmail")) // HTML editor with special mail rules
|
||||
{
|
||||
err = editor->Init(aDoc, aPresShell, nsIHTMLEditor::eEditorMailMask);
|
||||
err = editor->Init(aDoc, aPresShell, selCon, nsIHTMLEditor::eEditorMailMask);
|
||||
mEditorType = eHTMLTextEditorType;
|
||||
}
|
||||
else
|
||||
|
||||
@ -67,7 +67,7 @@ NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData *aElement,
|
||||
PRUint32 aReplaceLength,
|
||||
nsIPrivateTextRangeList *aTextRangeList,
|
||||
const nsString &aStringToInsert,
|
||||
nsWeakPtr aPresShellWeak)
|
||||
nsWeakPtr aSelConWeak)
|
||||
{
|
||||
NS_ASSERTION(aElement, "illegal value- null ptr- aElement");
|
||||
NS_ASSERTION(aTextRangeList, "illegal value- null ptr - aTextRangeList");
|
||||
@ -77,7 +77,7 @@ NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData *aElement,
|
||||
mOffset = aOffset;
|
||||
mReplaceLength = aReplaceLength;
|
||||
mStringToInsert = aStringToInsert;
|
||||
mPresShellWeak = aPresShellWeak;
|
||||
mSelConWeak = aSelConWeak;
|
||||
mRangeList = do_QueryInterface(aTextRangeList);
|
||||
mFixed = PR_FALSE;
|
||||
return NS_OK;
|
||||
@ -90,8 +90,8 @@ NS_IMETHODIMP IMETextTxn::Do(void)
|
||||
printf("Do IME Text element = %p replace = %d len = %d\n", mElement.get(), mReplaceLength, mStringToInsert.Length());
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
|
||||
if (!ps) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mSelConWeak);
|
||||
if (!selCon) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// advance caret: This requires the presentation shell to get the selection.
|
||||
nsresult result = NS_OK;
|
||||
@ -113,7 +113,7 @@ NS_IMETHODIMP IMETextTxn::Undo(void)
|
||||
printf("Undo IME Text element = %p\n", mElement.get());
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mPresShellWeak);
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mSelConWeak);
|
||||
if (!selCon) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult result;
|
||||
@ -309,7 +309,7 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void)
|
||||
//
|
||||
// run through the text range list, if any
|
||||
//
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mPresShellWeak);
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mSelConWeak);
|
||||
if (!selCon) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
result = mRangeList->GetLength(&textRangeListLength);
|
||||
|
||||
@ -59,14 +59,14 @@ public:
|
||||
* @param aOffset the location in aElement to do the insertion
|
||||
* @param aReplaceLength the length of text to replace (0= no replacement)
|
||||
* @param aString the new text to insert
|
||||
* @param aPresShell used to get and set the selection
|
||||
* @param aSelCon used to get and set the selection
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDOMCharacterData *aElement,
|
||||
PRUint32 aOffset,
|
||||
PRUint32 aReplaceLength,
|
||||
nsIPrivateTextRangeList* aTextRangeList,
|
||||
const nsString& aString,
|
||||
nsWeakPtr aPresShell);
|
||||
nsWeakPtr aSelCon);
|
||||
|
||||
private:
|
||||
|
||||
@ -120,8 +120,8 @@ protected:
|
||||
/** the range list **/
|
||||
nsCOMPtr<nsIPrivateTextRangeList> mRangeList;
|
||||
|
||||
/** the presentation shell, which we'll need to get the selection */
|
||||
nsWeakPtr mPresShellWeak; // use a weak reference
|
||||
/** the selection controller, which we'll need to get the selection */
|
||||
nsWeakPtr mSelConWeak; // use a weak reference
|
||||
|
||||
PRBool mFixed;
|
||||
|
||||
|
||||
@ -24,7 +24,6 @@
|
||||
#include "nsEditor.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "EditAggregateTxn.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMSelectionIID, NS_IDOMSELECTION_IID);
|
||||
|
||||
@ -825,8 +825,9 @@ NS_IMPL_QUERY_INTERFACE3(nsEditor, nsIEditor, nsIEditorIMESupport, nsISupportsWe
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell, PRUint32 aFlags)
|
||||
nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell, nsISelectionController *aSelCon, PRUint32 aFlags)
|
||||
{
|
||||
NS_PRECONDITION(nsnull!=aDoc && nsnull!=aPresShell, "bad arg");
|
||||
if ((nsnull==aDoc) || (nsnull==aPresShell))
|
||||
@ -835,6 +836,7 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell, PRUint32 aFlags)
|
||||
mFlags = aFlags;
|
||||
mDocWeak = getter_AddRefs( NS_GetWeakReference(aDoc) ); // weak reference to doc
|
||||
mPresShellWeak = getter_AddRefs( NS_GetWeakReference(aPresShell) ); // weak reference to pres shell
|
||||
mSelConWeak = getter_AddRefs( NS_GetWeakReference(aSelCon) ); // weak reference to selectioncontroller
|
||||
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
|
||||
if (!ps) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
@ -914,7 +916,8 @@ nsEditor::GetDocument(nsIDOMDocument **aDoc)
|
||||
if (!mDocWeak) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsCOMPtr<nsIDOMDocument> doc = do_QueryReferent(mDocWeak);
|
||||
if (!doc) return NS_ERROR_NOT_INITIALIZED;
|
||||
return doc->QueryInterface(NS_GET_IID(nsIDOMDocument), (void **)aDoc);
|
||||
NS_ADDREF(*aDoc = doc);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -939,9 +942,9 @@ nsEditor::GetSelectionController(nsISelectionController **aSel)
|
||||
if (!aSel)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aSel = nsnull; // init out param
|
||||
NS_PRECONDITION(mPresShellWeak, "bad state, null mPresShellWeak");
|
||||
if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mPresShellWeak);
|
||||
NS_PRECONDITION(mSelConWeak, "bad state, null mSelConWeak");
|
||||
if (!mSelConWeak) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mSelConWeak);
|
||||
if (!selCon) return NS_ERROR_NOT_INITIALIZED;
|
||||
NS_ADDREF(*aSel = selCon);
|
||||
return NS_OK;
|
||||
@ -955,8 +958,8 @@ nsEditor::GetSelection(nsIDOMSelection **aSelection)
|
||||
if (!aSelection)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aSelection = nsnull;
|
||||
if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsCOMPtr<nsISelectionController> selcon = do_QueryReferent(mPresShellWeak);
|
||||
if (!mSelConWeak) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsCOMPtr<nsISelectionController> selcon = do_QueryReferent(mSelConWeak);
|
||||
if (!selcon) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsresult result = selcon->GetSelection(nsISelectionController::SELECTION_NORMAL, aSelection); // does an addref
|
||||
return result;
|
||||
@ -4928,7 +4931,7 @@ nsresult nsEditor::EndUpdateViewBatch()
|
||||
mViewManager->EndUpdateViewBatch(NS_VMREFRESH_IMMEDIATE);
|
||||
#endif
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
nsresult rv = GetPresShell(getter_AddRefs(presShell));
|
||||
rv = GetPresShell(getter_AddRefs(presShell));
|
||||
if (NS_SUCCEEDED(rv) && presShell)
|
||||
presShell->EndReflowBatching(PR_TRUE);
|
||||
}
|
||||
@ -5197,7 +5200,7 @@ nsEditor::CreateTxnForIMEText(const nsString & aStringToInsert,
|
||||
|
||||
result = TransactionFactory::GetNewTransaction(IMETextTxn::GetCID(), (EditTxn **)aTxn);
|
||||
if (nsnull!=*aTxn) {
|
||||
result = (*aTxn)->Init(mIMETextNode,mIMETextOffset,mIMEBufferLength,mIMETextRangeList,aStringToInsert,mPresShellWeak);
|
||||
result = (*aTxn)->Init(mIMETextNode,mIMETextOffset,mIMEBufferLength,mIMETextRangeList,aStringToInsert,mSelConWeak);
|
||||
}
|
||||
else {
|
||||
result = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
@ -70,6 +70,8 @@ class IMETextTxn;
|
||||
class AddStyleSheetTxn;
|
||||
class RemoveStyleSheetTxn;
|
||||
class nsFileSpec;
|
||||
class nsISelectionController;
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* class for recording selection info. stores selection as collection of
|
||||
@ -187,7 +189,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/* ------------ nsIEditor methods -------------- */
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, PRUint32 aFlags);
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsISelectionController *aSelCon, PRUint32 aFlags);
|
||||
NS_IMETHOD PostCreate();
|
||||
NS_IMETHOD GetFlags(PRUint32 *aFlags) = 0;
|
||||
NS_IMETHOD SetFlags(PRUint32 aFlags) = 0;
|
||||
@ -725,6 +727,7 @@ protected:
|
||||
PRUint32 mFlags; // behavior flags. See nsIHTMLEditor.h for the flags we use.
|
||||
|
||||
nsWeakPtr mPresShellWeak; // weak reference to the nsIPresShell
|
||||
nsWeakPtr mSelConWeak; // weak reference to the nsISelectionController
|
||||
nsIViewManager *mViewManager;
|
||||
PRInt32 mUpdateCount;
|
||||
nsCOMPtr<nsITransactionManager> mTxnMgr;
|
||||
|
||||
@ -380,7 +380,7 @@ NS_IMETHODIMP nsHTMLEditor::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::Init(nsIDOMDocument *aDoc,
|
||||
nsIPresShell *aPresShell, PRUint32 aFlags)
|
||||
nsIPresShell *aPresShell, nsISelectionController *aSelCon, PRUint32 aFlags)
|
||||
{
|
||||
NS_PRECONDITION(aDoc && aPresShell, "bad arg");
|
||||
if (!aDoc || !aPresShell)
|
||||
@ -388,7 +388,7 @@ NS_IMETHODIMP nsHTMLEditor::Init(nsIDOMDocument *aDoc,
|
||||
|
||||
nsresult result = NS_ERROR_NULL_POINTER;
|
||||
// Init the base editor
|
||||
result = nsEditor::Init(aDoc, aPresShell, aFlags);
|
||||
result = nsEditor::Init(aDoc, aPresShell, aSelCon, aFlags);
|
||||
if (NS_FAILED(result)) { return result; }
|
||||
|
||||
nsCOMPtr<nsIDOMElement> bodyElement;
|
||||
|
||||
@ -242,7 +242,7 @@ public:
|
||||
/* ------------ Overrides of nsEditor interface methods -------------- */
|
||||
|
||||
/** prepare the editor for use */
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, PRUint32 aFlags);
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsISelectionController *aSelCon, PRUint32 aFlags);
|
||||
|
||||
NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet);
|
||||
|
||||
|
||||
@ -22,7 +22,6 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
||||
@ -477,12 +477,6 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||
if (!editor) { return NS_OK; }
|
||||
|
||||
|
||||
// get the document
|
||||
nsCOMPtr<nsIDOMDocument>domDoc;
|
||||
editor->GetDocument(getter_AddRefs(domDoc));
|
||||
if (!domDoc) { return NS_OK; }
|
||||
nsCOMPtr<nsIDocument>doc = do_QueryInterface(domDoc);
|
||||
if (!doc) { return NS_OK; }
|
||||
|
||||
PRUint16 button = 0;
|
||||
mouseEvent->GetButton(&button);
|
||||
@ -1083,16 +1077,7 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
|
||||
selCon->SetCaretEnabled(PR_TRUE);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMDocument>domDoc;
|
||||
editor->GetDocument(getter_AddRefs(domDoc));
|
||||
if (domDoc)
|
||||
{
|
||||
nsCOMPtr<nsIDocument>doc = do_QueryInterface(domDoc);
|
||||
if (doc)
|
||||
{
|
||||
doc->SetDisplaySelection(nsIDocument::SELECTION_ON);
|
||||
}
|
||||
}
|
||||
selCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
|
||||
#ifdef USE_HACK_REPAINT
|
||||
// begin hack repaint
|
||||
nsCOMPtr<nsIViewManager> viewmgr;
|
||||
@ -1131,17 +1116,7 @@ nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent)
|
||||
if (selCon)
|
||||
{
|
||||
selCon->SetCaretEnabled(PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIDOMDocument>domDoc;
|
||||
editor->GetDocument(getter_AddRefs(domDoc));
|
||||
if (domDoc)
|
||||
{
|
||||
nsCOMPtr<nsIDocument>doc = do_QueryInterface(domDoc);
|
||||
if (doc)
|
||||
{
|
||||
doc->SetDisplaySelection(nsIDocument::SELECTION_DISABLED);
|
||||
}
|
||||
}
|
||||
selCon->SetDisplaySelection(nsISelectionController::SELECTION_DISABLED);
|
||||
#ifdef USE_HACK_REPAINT
|
||||
// begin hack repaint
|
||||
nsCOMPtr<nsIViewManager> viewmgr;
|
||||
|
||||
@ -72,7 +72,7 @@ public:
|
||||
* linked to a single pres shell.
|
||||
* @param aFlags A bitmask of flags for specifying the behavior of the editor.
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, PRUint32 aFlags)=0;
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsISelectionController *aSelCon, PRUint32 aFlags)=0;
|
||||
|
||||
/**
|
||||
* PostCreate should be called after Init, and is the time that the editor tells
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user