Back to index

lightning-sunbird  0.9+nobinonly
nsEditor.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Daniel Glazman <glazman@netscape.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #ifndef __editor_h__
00040 #define __editor_h__
00041 
00042 #include "nsCOMPtr.h"
00043 #include "nsWeakReference.h"
00044 
00045 #include "nsIEditor.h"
00046 #include "nsIEditorIMESupport.h"
00047 #include "nsIPhonetic.h"
00048 #include "nsIKBStateControl.h"
00049 
00050 #include "nsIAtom.h"
00051 #include "nsIDOMDocument.h"
00052 #include "nsISelection.h"
00053 #include "nsIDOMCharacterData.h"
00054 #include "nsIPrivateTextRange.h"
00055 #include "nsITransactionManager.h"
00056 #include "nsIComponentManager.h"
00057 #include "nsISupportsArray.h"
00058 #include "nsICSSStyleSheet.h"
00059 #include "nsIDTD.h"
00060 #include "nsIDOMElement.h"
00061 #include "nsSelectionState.h"
00062 #include "nsIEditorSpellCheck.h"
00063 #include "nsIInlineSpellChecker.h"
00064 
00065 class nsIEditActionListener;
00066 class nsIDocumentStateListener;
00067 class nsIDOMCharacterData;
00068 class nsIDOMRange;
00069 class nsIPresShell;
00070 class nsIViewManager;
00071 class ChangeAttributeTxn;
00072 class CreateElementTxn;
00073 class InsertElementTxn;
00074 class DeleteElementTxn;
00075 class InsertTextTxn;
00076 class DeleteTextTxn;
00077 class SplitElementTxn;
00078 class JoinElementTxn;
00079 class EditAggregateTxn;
00080 class nsVoidArray;
00081 class nsISupportsArray;
00082 class nsILocale;
00083 class IMETextTxn;
00084 class AddStyleSheetTxn;
00085 class RemoveStyleSheetTxn;
00086 class nsIFile;
00087 class nsISelectionController;
00088 class nsIDOMEventReceiver;
00089 
00090 #define kMOZEditorBogusNodeAttr NS_LITERAL_STRING("_moz_editor_bogus_node")
00091 #define kMOZEditorBogusNodeValue NS_LITERAL_STRING("TRUE")
00092 
00098 class nsEditor : public nsIEditor_MOZILLA_1_8_BRANCH,
00099                  public nsIEditorIMESupport,
00100                  public nsSupportsWeakReference,
00101                  public nsIPhonetic
00102 {
00103 public:
00104 
00105   enum IterDirection
00106   {
00107     kIterForward,
00108     kIterBackward
00109   };
00110 
00111   enum OperationID
00112   {
00113     kOpIgnore = -1,
00114     kOpNone = 0,
00115     kOpUndo,
00116     kOpRedo,
00117     kOpInsertNode,
00118     kOpCreateNode,
00119     kOpDeleteNode,
00120     kOpSplitNode,
00121     kOpJoinNode,
00122     kOpDeleteSelection,
00123     // text commands
00124     kOpInsertBreak    = 1000,
00125     kOpInsertText     = 1001,
00126     kOpInsertIMEText  = 1002,
00127     kOpDeleteText     = 1003
00128   };
00129 
00133   nsEditor();
00137   virtual ~nsEditor();
00138 
00139 //Interfaces for addref and release and queryinterface
00140 //NOTE: Use   NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
00141   NS_DECL_ISUPPORTS
00142 
00143   /* ------------ utility methods   -------------- */
00144   NS_IMETHOD GetPresShell(nsIPresShell **aPS);
00145   void NotifyEditorObservers(void);
00146 
00147   /* ------------ nsIEditor methods -------------- */
00148   NS_DECL_NSIEDITOR
00149   NS_DECL_NSIEDITOR_MOZILLA_1_8_BRANCH
00150   /* ------------ nsIEditorIMESupport methods -------------- */
00151   NS_DECL_NSIEDITORIMESUPPORT
00152   
00153   // nsIPhonetic
00154   NS_DECL_NSIPHONETIC
00155 
00156 
00157 public:
00158 
00159   
00160   NS_IMETHOD InsertTextImpl(const nsAString& aStringToInsert, 
00161                                nsCOMPtr<nsIDOMNode> *aInOutNode, 
00162                                PRInt32 *aInOutOffset,
00163                                nsIDOMDocument *aDoc);
00164   NS_IMETHOD InsertTextIntoTextNodeImpl(const nsAString& aStringToInsert, 
00165                                            nsIDOMCharacterData *aTextNode, 
00166                                            PRInt32 aOffset, PRBool suppressIME=PR_FALSE);
00167   NS_IMETHOD DeleteSelectionImpl(EDirection aAction);
00168   NS_IMETHOD DeleteSelectionAndCreateNode(const nsAString& aTag,
00169                                            nsIDOMNode ** aNewNode);
00170 
00171   /* helper routines for node/parent manipulations */
00172   nsresult ReplaceContainer(nsIDOMNode *inNode, 
00173                             nsCOMPtr<nsIDOMNode> *outNode, 
00174                             const nsAString &aNodeType,
00175                             const nsAString *aAttribute = nsnull,
00176                             const nsAString *aValue = nsnull,
00177                             PRBool aCloneAttributes = PR_FALSE);
00178 
00179   nsresult RemoveContainer(nsIDOMNode *inNode);
00180   nsresult InsertContainerAbove(nsIDOMNode *inNode, 
00181                                 nsCOMPtr<nsIDOMNode> *outNode, 
00182                                 const nsAString &aNodeType,
00183                                 const nsAString *aAttribute = nsnull,
00184                                 const nsAString *aValue = nsnull);
00185   nsresult MoveNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aOffset);
00186 
00187   /* Method to replace certain CreateElementNS() calls. 
00188      Arguments:
00189       nsString& aTag          - tag you want
00190       nsIContent** aContent   - returned Content that was created with above namespace.
00191   */
00192   nsresult CreateHTMLContent(const nsAString& aTag, nsIContent** aContent);
00193 
00194 protected:
00195 
00196   /*
00197   NS_IMETHOD SetProperties(nsVoidArray *aPropList);
00198   NS_IMETHOD GetProperties(nsVoidArray *aPropList);
00199   */
00200   
00201   nsCString mContentMIMEType;       // MIME type of the doc we are editing.
00202 
00205   NS_IMETHOD CreateTxnForSetAttribute(nsIDOMElement *aElement, 
00206                                       const nsAString &  aAttribute, 
00207                                       const nsAString &  aValue,
00208                                       ChangeAttributeTxn ** aTxn);
00209 
00212   NS_IMETHOD CreateTxnForRemoveAttribute(nsIDOMElement *aElement, 
00213                                          const nsAString &  aAttribute,
00214                                          ChangeAttributeTxn ** aTxn);
00215 
00218   NS_IMETHOD CreateTxnForCreateElement(const nsAString & aTag,
00219                                        nsIDOMNode     *aParent,
00220                                        PRInt32         aPosition,
00221                                        CreateElementTxn ** aTxn);
00222 
00225   NS_IMETHOD CreateTxnForInsertElement(nsIDOMNode * aNode,
00226                                        nsIDOMNode * aParent,
00227                                        PRInt32      aOffset,
00228                                        InsertElementTxn ** aTxn);
00229 
00232   NS_IMETHOD CreateTxnForDeleteElement(nsIDOMNode * aElement,
00233                                        DeleteElementTxn ** aTxn);
00234 
00235 
00236   NS_IMETHOD CreateTxnForDeleteSelection(EDirection aAction,
00237                                               EditAggregateTxn  ** aTxn);
00238 
00239   NS_IMETHOD CreateTxnForDeleteInsertionPoint(nsIDOMRange         *aRange, 
00240                                               EDirection aAction, 
00241                                               EditAggregateTxn    *aTxn);
00242 
00243 
00247   NS_IMETHOD CreateTxnForInsertText(const nsAString & aStringToInsert,
00248                                     nsIDOMCharacterData *aTextNode,
00249                                     PRInt32 aOffset,
00250                                     InsertTextTxn ** aTxn);
00251 
00252   NS_IMETHOD CreateTxnForIMEText(const nsAString & aStringToInsert,
00253                                  IMETextTxn ** aTxn);
00254 
00257   NS_IMETHOD CreateTxnForAddStyleSheet(nsICSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn);
00258 
00261   NS_IMETHOD CreateTxnForRemoveStyleSheet(nsICSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn);
00262   
00263   NS_IMETHOD DeleteText(nsIDOMCharacterData *aElement,
00264                         PRUint32             aOffset,
00265                         PRUint32             aLength);
00266 
00267 //  NS_IMETHOD DeleteRange(nsIDOMRange *aRange);
00268 
00269   NS_IMETHOD CreateTxnForDeleteText(nsIDOMCharacterData *aElement,
00270                                     PRUint32             aOffset,
00271                                     PRUint32             aLength,
00272                                     DeleteTextTxn      **aTxn);
00273        
00274   NS_IMETHOD CreateTxnForSplitNode(nsIDOMNode *aNode,
00275                                    PRUint32    aOffset,
00276                                    SplitElementTxn **aTxn);
00277 
00278   NS_IMETHOD CreateTxnForJoinNode(nsIDOMNode  *aLeftNode,
00279                                   nsIDOMNode  *aRightNode,
00280                                   JoinElementTxn **aTxn);
00281 
00282   NS_IMETHOD DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNode> &parentSelectedNode, 
00283                                                    PRInt32& offsetOfNewNode);
00284 
00285   // called after a transaction is done successfully
00286   NS_IMETHOD DoAfterDoTransaction(nsITransaction *aTxn);
00287   // called after a transaction is undone successfully
00288   NS_IMETHOD DoAfterUndoTransaction();
00289   // called after a transaction is redone successfully
00290   NS_IMETHOD DoAfterRedoTransaction();
00291 
00292   typedef enum {
00293     eDocumentCreated,
00294     eDocumentToBeDestroyed,
00295     eDocumentStateChanged
00296   } TDocumentListenerNotification;
00297   
00298   // tell the doc state listeners that the doc state has changed
00299   NS_IMETHOD NotifyDocumentListeners(TDocumentListenerNotification aNotificationType);
00300   
00302   NS_IMETHOD SelectEntireDocument(nsISelection *aSelection);
00303 
00304   /* Helper for output routines -- we expect subclasses to override this */
00305   NS_IMETHOD GetWrapWidth(PRInt32* aWrapCol);
00306 
00317   NS_IMETHOD ScrollSelectionIntoView(PRBool aScrollToAnchor);
00318 
00319   // stub.  see comment in source.                     
00320   virtual PRBool IsBlockNode(nsIDOMNode *aNode);
00321   
00322   // helper for GetPriorNode
00323   nsresult GetPriorNodeImpl(nsIDOMNode  *aCurrentNode, 
00324                             PRBool       aEditableNode,
00325                             nsCOMPtr<nsIDOMNode> *aResultNode,
00326                             PRBool       bNoBlockCrossing = PR_FALSE);
00327 
00328   // helper for GetNextNode
00329   nsresult GetNextNodeImpl(nsIDOMNode  *aCurrentNode, 
00330                            PRBool       aEditableNode,
00331                            nsCOMPtr<nsIDOMNode> *aResultNode,
00332                            PRBool       bNoBlockCrossing = PR_FALSE);
00333 
00334   // Get nsIKBStateControl interface
00335   nsresult GetKBStateControl(nsIKBStateControl **aKBSC);
00336 
00337 
00338   // install the event listeners for the editor 
00339   nsresult InstallEventListeners();
00340 
00341   virtual nsresult CreateEventListeners() = 0;
00342 
00343   // unregister and release our event listeners
00344   virtual void RemoveEventListeners();
00345 
00349   PRBool GetDesiredSpellCheckState();
00350 
00351 public:
00352 
00355   NS_IMETHOD StartOperation(PRInt32 opID, nsIEditor::EDirection aDirection);
00356 
00359   NS_IMETHOD EndOperation();
00360 
00363   PRBool   ArePreservingSelection();
00364   nsresult PreserveSelectionAcrossActions(nsISelection *aSel);
00365   nsresult RestorePreservedSelection(nsISelection *aSel);
00366   void     StopPreservingSelection();
00367 
00368 
00370   static nsresult GetTextNodeTag(nsAString& aOutString);
00371 
00379   nsresult SplitNodeImpl(nsIDOMNode *aExistingRightNode,
00380                          PRInt32     aOffset,
00381                          nsIDOMNode *aNewLeftNode,
00382                          nsIDOMNode *aParent);
00383 
00393   nsresult JoinNodesImpl(nsIDOMNode *aNodeToKeep,
00394                          nsIDOMNode *aNodeToJoin,
00395                          nsIDOMNode *aParent,
00396                          PRBool      aNodeToKeepIsFirst);
00397 
00402   static nsresult GetChildOffset(nsIDOMNode *aChild, 
00403                                  nsIDOMNode *aParent, 
00404                                  PRInt32    &aOffset);
00405 
00410   static nsresult GetNodeLocation(nsIDOMNode *aChild, 
00411                                  nsCOMPtr<nsIDOMNode> *aParent, 
00412                                  PRInt32    *aOffset);
00413 
00420   static nsresult GetLengthOfDOMNode(nsIDOMNode *aNode, PRUint32 &aCount);
00421 
00429   nsresult GetPriorNode(nsIDOMNode  *aCurrentNode, 
00430                         PRBool       aEditableNode,
00431                         nsCOMPtr<nsIDOMNode> *aResultNode,
00432                         PRBool       bNoBlockCrossing = PR_FALSE);
00433 
00434   // and another version that takes a {parent,offset} pair rather than a node
00435   nsresult GetPriorNode(nsIDOMNode  *aParentNode, 
00436                         PRInt32      aOffset, 
00437                         PRBool       aEditableNode, 
00438                         nsCOMPtr<nsIDOMNode> *aResultNode,
00439                         PRBool       bNoBlockCrossing = PR_FALSE);
00440                        
00448   nsresult GetNextNode(nsIDOMNode  *aCurrentNode, 
00449                        PRBool       aEditableNode,
00450                        nsCOMPtr<nsIDOMNode> *aResultNode,
00451                        PRBool       bNoBlockCrossing = PR_FALSE);
00452 
00453   // and another version that takes a {parent,offset} pair rather than a node
00454   nsresult GetNextNode(nsIDOMNode  *aParentNode, 
00455                        PRInt32      aOffset, 
00456                        PRBool       aEditableNode, 
00457                        nsCOMPtr<nsIDOMNode> *aResultNode,
00458                        PRBool       bNoBlockCrossing = PR_FALSE);
00459 
00463   nsCOMPtr<nsIDOMNode> GetRightmostChild(nsIDOMNode *aCurrentNode, 
00464                                          PRBool      bNoBlockCrossing = PR_FALSE);
00465 
00469   nsCOMPtr<nsIDOMNode> GetLeftmostChild(nsIDOMNode  *aCurrentNode, 
00470                                          PRBool      bNoBlockCrossing = PR_FALSE);
00471 
00473   static inline PRBool NodeIsType(nsIDOMNode *aNode, nsIAtom *aTag)
00474   {
00475     return GetTag(aNode) == aTag;
00476   }
00477 
00478   // we should get rid of this method if we can
00479   static inline PRBool NodeIsTypeString(nsIDOMNode *aNode, const nsAString &aTag)
00480   {
00481     nsIAtom *nodeAtom = GetTag(aNode);
00482     return nodeAtom && nodeAtom->Equals(aTag);
00483   }
00484 
00485 
00487   PRBool CanContainTag(nsIDOMNode* aParent, const nsAString &aTag);
00488   PRBool TagCanContain(const nsAString &aParentTag, nsIDOMNode* aChild);
00489   virtual PRBool TagCanContainTag(const nsAString &aParentTag, const nsAString &aChildTag);
00490 
00492   PRBool IsRootNode(nsIDOMNode *inNode);
00493 
00495   PRBool IsDescendantOfBody(nsIDOMNode *inNode);
00496 
00498   PRBool IsContainer(nsIDOMNode *aNode);
00499 
00501   PRBool IsEditable(nsIDOMNode *aNode);
00502 
00503   virtual PRBool IsTextInDirtyFrameVisible(nsIDOMNode *aNode);
00504 
00506   PRBool IsMozEditorBogusNode(nsIDOMNode *aNode);
00507 
00509   PRBool IsEmptyTextContent(nsIContent* aContent);
00510 
00512   nsresult CountEditableChildren(nsIDOMNode *aNode, PRUint32 &outCount);
00513   
00515   nsresult GetFirstEditableNode(nsIDOMNode *aRoot, nsCOMPtr<nsIDOMNode> *outFirstNode);
00516 #ifdef XXX_DEAD_CODE
00517   nsresult GetLastEditableNode(nsIDOMNode *aRoot, nsCOMPtr<nsIDOMNode> *outLastNode);
00518 #endif
00519 
00520   nsresult GetIMEBufferLength(PRInt32* length);
00521   PRBool   IsIMEComposing();    /* test if IME is in composition state */
00522   void     SetIsIMEComposing(); /* call this before |IsIMEComposing()| */
00523 
00525   static nsresult GetTagString(nsIDOMNode *aNode, nsAString& outString);
00526   static nsIAtom *GetTag(nsIDOMNode *aNode);
00527   virtual PRBool NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2);
00528   static PRBool IsTextOrElementNode(nsIDOMNode *aNode);
00529   static PRBool IsTextNode(nsIDOMNode *aNode);
00530   
00531   static PRInt32 GetIndexOf(nsIDOMNode *aParent, nsIDOMNode *aChild);
00532   static nsCOMPtr<nsIDOMNode> GetChildAt(nsIDOMNode *aParent, PRInt32 aOffset);
00533   
00534   static nsresult GetStartNodeAndOffset(nsISelection *aSelection, nsCOMPtr<nsIDOMNode> *outStartNode, PRInt32 *outStartOffset);
00535   static nsresult GetEndNodeAndOffset(nsISelection *aSelection, nsCOMPtr<nsIDOMNode> *outEndNode, PRInt32 *outEndOffset);
00536 #if DEBUG_JOE
00537   static void DumpNode(nsIDOMNode *aNode, PRInt32 indent=0);
00538 #endif
00539 
00540   // Helpers to add a node to the selection. 
00541   // Used by table cell selection methods
00542   nsresult CreateRange(nsIDOMNode *aStartParent, PRInt32 aStartOffset,
00543                        nsIDOMNode *aEndParent, PRInt32 aEndOffset,
00544                        nsIDOMRange **aRange);
00545 
00546   // Creates a range with just the supplied node and appends that to the selection
00547   nsresult AppendNodeToSelectionAsRange(nsIDOMNode *aNode);
00548   // When you are using AppendNodeToSelectionAsRange, call this first to start a new selection
00549   nsresult ClearSelection();
00550 
00551   nsresult IsPreformatted(nsIDOMNode *aNode, PRBool *aResult);
00552 
00553   nsresult SplitNodeDeep(nsIDOMNode *aNode, 
00554                          nsIDOMNode *aSplitPointParent, 
00555                          PRInt32 aSplitPointOffset,
00556                          PRInt32 *outOffset,
00557                          PRBool  aNoEmptyContainers = PR_FALSE,
00558                          nsCOMPtr<nsIDOMNode> *outLeftNode = 0,
00559                          nsCOMPtr<nsIDOMNode> *outRightNode = 0);
00560   nsresult JoinNodeDeep(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsCOMPtr<nsIDOMNode> *aOutJoinNode, PRInt32 *outOffset); 
00561 
00562   nsresult GetString(const nsAString& name, nsAString& value);
00563 
00564   nsresult BeginUpdateViewBatch(void);
00565   virtual nsresult EndUpdateViewBatch(void);
00566 
00567   PRBool GetShouldTxnSetSelection();
00568 
00569   nsresult HandleInlineSpellCheck(PRInt32 action,
00570                                     nsISelection *aSelection,
00571                                     nsIDOMNode *previousSelectedNode,
00572                                     PRInt32 previousSelectedOffset,
00573                                     nsIDOMNode *aStartNode,
00574                                     PRInt32 aStartOffset,
00575                                     nsIDOMNode *aEndNode,
00576                                     PRInt32 aEndOffset);
00577 
00578   already_AddRefed<nsIDOMEventReceiver> GetDOMEventReceiver();
00579 
00580   // Fast non-refcounting editor root element accessor
00581   nsIDOMElement *GetRoot();
00582 
00583 public:
00584   // Argh!  These transaction names are used by PlaceholderTxn and
00585   // nsPlaintextEditor.  They should be localized to those classes.
00586   static nsIAtom *gTypingTxnName;
00587   static nsIAtom *gIMETxnName;
00588   static nsIAtom *gDeleteTxnName;
00589 
00590 protected:
00591 
00592   PRUint32        mModCount;              // number of modifications (for undo/redo stack)
00593   PRUint32        mFlags;          // behavior flags. See nsPlaintextEditor.h for the flags we use.
00594   
00595   nsWeakPtr       mPresShellWeak;   // weak reference to the nsIPresShell
00596   nsWeakPtr       mSelConWeak;   // weak reference to the nsISelectionController
00597   nsIViewManager *mViewManager;
00598   PRInt32         mUpdateCount;
00599 
00600   // Spellchecking
00601   enum Tristate {
00602     eTriUnset,
00603     eTriFalse,
00604     eTriTrue
00605   }                 mSpellcheckCheckboxState;
00606   nsCOMPtr<nsIInlineSpellChecker> mInlineSpellChecker;
00607 
00608   nsCOMPtr<nsITransactionManager> mTxnMgr;
00609   nsWeakPtr         mPlaceHolderTxn;     // weak reference to placeholder for begin/end batch purposes
00610   nsIAtom          *mPlaceHolderName;    // name of placeholder transaction
00611   PRInt32           mPlaceHolderBatch;   // nesting count for batching
00612   nsSelectionState *mSelState;           // saved selection state for placeholder txn batching
00613   nsSelectionState  mSavedSel;           // cached selection for nsAutoSelectionReset
00614   nsRangeUpdater    mRangeUpdater;       // utility class object for maintaining preserved ranges
00615   nsCOMPtr<nsIDOMElement> mRootElement;    // cached root node
00616   PRInt32           mAction;             // the current editor action
00617   EDirection        mDirection;          // the current direction of editor action
00618   
00619   // data necessary to build IME transactions
00620   nsIPrivateTextRangeList*      mIMETextRangeList; // IME special selection ranges
00621   nsCOMPtr<nsIDOMCharacterData> mIMETextNode;      // current IME text node
00622   PRUint32                      mIMETextOffset;    // offset in text node where IME comp string begins
00623   PRUint32                      mIMEBufferLength;  // current length of IME comp string
00624   PRPackedBool                  mInIMEMode;        // are we inside an IME composition?
00625   PRPackedBool                  mIsIMEComposing;   // is IME in composition state?
00626                                                    // This is different from mInIMEMode. see Bug 98434.
00627   PRPackedBool                  mNeedRecoverIMEOpenState;   // Need IME open state change on blur.
00628 
00629   PRPackedBool                  mShouldTxnSetSelection;  // turn off for conservative selection adjustment by txns
00630   PRPackedBool                  mDidPreDestroy;    // whether PreDestroy has been called
00631   // various listeners
00632   nsVoidArray*                  mActionListeners;  // listens to all low level actions on the doc
00633   nsVoidArray*                  mEditorObservers;  // just notify once per high level change
00634   nsCOMPtr<nsISupportsArray>    mDocStateListeners;// listen to overall doc state (dirty or not, just created, etc)
00635 
00636   PRInt8                        mDocDirtyState;         // -1 = not initialized
00637   nsWeakPtr        mDocWeak;  // weak reference to the nsIDOMDocument
00638   // The form field as an event receiver
00639   nsCOMPtr<nsIDOMEventReceiver> mDOMEventReceiver;
00640   nsCOMPtr<nsIDTD> mDTD;
00641 
00642   nsString* mPhonetic;
00643 
00644   nsCOMPtr<nsIDOMEventListener> mKeyListenerP;
00645   nsCOMPtr<nsIDOMEventListener> mMouseListenerP;
00646   nsCOMPtr<nsIDOMEventListener> mTextListenerP;
00647   nsCOMPtr<nsIDOMEventListener> mCompositionListenerP;
00648   nsCOMPtr<nsIDOMEventListener> mDragListenerP;
00649   nsCOMPtr<nsIDOMEventListener> mFocusListenerP;
00650 
00651   friend PRBool NSCanUnload(nsISupports* serviceMgr);
00652   friend class nsAutoTxnsConserveSelection;
00653   friend class nsAutoSelectionReset;
00654   friend class nsAutoRules;
00655   friend class nsRangeUpdater;
00656 };
00657 
00658 
00659 #endif