Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Friends
nsEditor Class Reference

implementation of an editor object. More...

#include <nsEditor.h>

Inheritance diagram for nsEditor:
Inheritance graph
[legend]
Collaboration diagram for nsEditor:
Collaboration graph
[legend]

List of all members.

Public Types

enum  IterDirection { kIterForward, kIterBackward }
enum  OperationID {
  kOpIgnore = -1, kOpNone = 0, kOpUndo, kOpRedo,
  kOpInsertNode, kOpCreateNode, kOpDeleteNode, kOpSplitNode,
  kOpJoinNode, kOpDeleteSelection, kOpInsertBreak = 1000, kOpInsertText = 1001,
  kOpInsertIMEText = 1002, kOpDeleteText = 1003
}
typedef short EDirection

Public Member Functions

 nsEditor ()
 The default constructor.
virtual ~nsEditor ()
 The default destructor.
NS_DECL_ISUPPORTS NS_IMETHOD GetPresShell (nsIPresShell **aPS)
void NotifyEditorObservers (void)
NS_IMETHOD InsertTextImpl (const nsAString &aStringToInsert, nsCOMPtr< nsIDOMNode > *aInOutNode, PRInt32 *aInOutOffset, nsIDOMDocument *aDoc)
NS_IMETHOD InsertTextIntoTextNodeImpl (const nsAString &aStringToInsert, nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRBool suppressIME=PR_FALSE)
NS_IMETHOD DeleteSelectionImpl (EDirection aAction)
NS_IMETHOD DeleteSelectionAndCreateNode (const nsAString &aTag, nsIDOMNode **aNewNode)
nsresult ReplaceContainer (nsIDOMNode *inNode, nsCOMPtr< nsIDOMNode > *outNode, const nsAString &aNodeType, const nsAString *aAttribute=nsnull, const nsAString *aValue=nsnull, PRBool aCloneAttributes=PR_FALSE)
nsresult RemoveContainer (nsIDOMNode *inNode)
nsresult InsertContainerAbove (nsIDOMNode *inNode, nsCOMPtr< nsIDOMNode > *outNode, const nsAString &aNodeType, const nsAString *aAttribute=nsnull, const nsAString *aValue=nsnull)
nsresult MoveNode (nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aOffset)
nsresult CreateHTMLContent (const nsAString &aTag, nsIContent **aContent)
NS_IMETHOD StartOperation (PRInt32 opID, nsIEditor::EDirection aDirection)
 All editor operations which alter the doc should be prefaced with a call to StartOperation, naming the action and direction.
NS_IMETHOD EndOperation ()
 All editor operations which alter the doc should be followed with a call to EndOperation.
PRBool ArePreservingSelection ()
 routines for managing the preservation of selection across various editor actions
nsresult PreserveSelectionAcrossActions (nsISelection *aSel)
nsresult RestorePreservedSelection (nsISelection *aSel)
void StopPreservingSelection ()
nsresult SplitNodeImpl (nsIDOMNode *aExistingRightNode, PRInt32 aOffset, nsIDOMNode *aNewLeftNode, nsIDOMNode *aParent)
 SplitNode() creates a new node identical to an existing node, and split the contents between the two nodes.
nsresult JoinNodesImpl (nsIDOMNode *aNodeToKeep, nsIDOMNode *aNodeToJoin, nsIDOMNode *aParent, PRBool aNodeToKeepIsFirst)
 JoinNodes() takes 2 nodes and merge their content|children.
nsresult GetPriorNode (nsIDOMNode *aCurrentNode, PRBool aEditableNode, nsCOMPtr< nsIDOMNode > *aResultNode, PRBool bNoBlockCrossing=PR_FALSE)
 get the node immediately prior to aCurrentNode
nsresult GetPriorNode (nsIDOMNode *aParentNode, PRInt32 aOffset, PRBool aEditableNode, nsCOMPtr< nsIDOMNode > *aResultNode, PRBool bNoBlockCrossing=PR_FALSE)
nsresult GetNextNode (nsIDOMNode *aCurrentNode, PRBool aEditableNode, nsCOMPtr< nsIDOMNode > *aResultNode, PRBool bNoBlockCrossing=PR_FALSE)
 get the node immediately after to aCurrentNode
nsresult GetNextNode (nsIDOMNode *aParentNode, PRInt32 aOffset, PRBool aEditableNode, nsCOMPtr< nsIDOMNode > *aResultNode, PRBool bNoBlockCrossing=PR_FALSE)
nsCOMPtr< nsIDOMNodeGetRightmostChild (nsIDOMNode *aCurrentNode, PRBool bNoBlockCrossing=PR_FALSE)
 Get the rightmost child of aCurrentNode; return nsnull if aCurrentNode has no children.
nsCOMPtr< nsIDOMNodeGetLeftmostChild (nsIDOMNode *aCurrentNode, PRBool bNoBlockCrossing=PR_FALSE)
 Get the leftmost child of aCurrentNode; return nsnull if aCurrentNode has no children.
PRBool CanContainTag (nsIDOMNode *aParent, const nsAString &aTag)
 returns PR_TRUE if aParent can contain a child of type aTag
PRBool TagCanContain (const nsAString &aParentTag, nsIDOMNode *aChild)
virtual PRBool TagCanContainTag (const nsAString &aParentTag, const nsAString &aChildTag)
PRBool IsRootNode (nsIDOMNode *inNode)
 returns PR_TRUE if aNode is our root node
PRBool IsDescendantOfBody (nsIDOMNode *inNode)
 returns PR_TRUE if aNode is a descendant of our root node
PRBool IsContainer (nsIDOMNode *aNode)
 returns PR_TRUE if aNode is a container
PRBool IsEditable (nsIDOMNode *aNode)
 returns PR_TRUE if aNode is an editable node
virtual PRBool IsTextInDirtyFrameVisible (nsIDOMNode *aNode)
PRBool IsMozEditorBogusNode (nsIDOMNode *aNode)
 returns PR_TRUE if aNode is a MozEditorBogus node
PRBool IsEmptyTextContent (nsIContent *aContent)
 returns PR_TRUE if content is an merely formatting whitespacce
nsresult CountEditableChildren (nsIDOMNode *aNode, PRUint32 &outCount)
 counts number of editable child nodes
nsresult GetFirstEditableNode (nsIDOMNode *aRoot, nsCOMPtr< nsIDOMNode > *outFirstNode)
 Find the deep first and last children.
nsresult GetIMEBufferLength (PRInt32 *length)
PRBool IsIMEComposing ()
void SetIsIMEComposing ()
virtual PRBool NodesSameType (nsIDOMNode *aNode1, nsIDOMNode *aNode2)
nsresult CreateRange (nsIDOMNode *aStartParent, PRInt32 aStartOffset, nsIDOMNode *aEndParent, PRInt32 aEndOffset, nsIDOMRange **aRange)
nsresult AppendNodeToSelectionAsRange (nsIDOMNode *aNode)
nsresult ClearSelection ()
nsresult IsPreformatted (nsIDOMNode *aNode, PRBool *aResult)
nsresult SplitNodeDeep (nsIDOMNode *aNode, nsIDOMNode *aSplitPointParent, PRInt32 aSplitPointOffset, PRInt32 *outOffset, PRBool aNoEmptyContainers=PR_FALSE, nsCOMPtr< nsIDOMNode > *outLeftNode=0, nsCOMPtr< nsIDOMNode > *outRightNode=0)
nsresult JoinNodeDeep (nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsCOMPtr< nsIDOMNode > *aOutJoinNode, PRInt32 *outOffset)
nsresult GetString (const nsAString &name, nsAString &value)
nsresult BeginUpdateViewBatch (void)
virtual nsresult EndUpdateViewBatch (void)
PRBool GetShouldTxnSetSelection ()
nsresult HandleInlineSpellCheck (PRInt32 action, nsISelection *aSelection, nsIDOMNode *previousSelectedNode, PRInt32 previousSelectedOffset, nsIDOMNode *aStartNode, PRInt32 aStartOffset, nsIDOMNode *aEndNode, PRInt32 aEndOffset)
already_AddRefed
< nsIDOMEventReceiver
GetDOMEventReceiver ()
nsIDOMElementGetRoot ()
nsIInlineSpellChecker getInlineSpellCheckerOptionally (in boolean autoCreate)
 Returns the inline spell checker associated with this object.
void syncRealTimeSpell ()
 Resyncs spellchecking state (enabled/disabled).
void setSpellcheckUserOverride (in boolean enable)
 Called when the user manually overrides the spellchecking state for this editor.
void init (in nsIDOMDocument doc, in nsIPresShellPtr shell, in nsIContentPtr aRoot, in nsISelectionController aSelCon, in unsigned long aFlags)
 Init is to tell the implementation of nsIEditor to begin its services.
void setAttributeOrEquivalent (in nsIDOMElement element, in AString sourceAttrName, in AString sourceAttrValue, in boolean aSuppressTransaction)
void removeAttributeOrEquivalent (in nsIDOMElement element, in DOMString sourceAttrName, in boolean aSuppressTransaction)
void postCreate ()
 postCreate should be called after Init, and is the time that the editor tells its documentStateObservers that the document has been created.
void preDestroy ()
 preDestroy is called before the editor goes away, and gives the editor a chance to tell its documentStateObservers that the document is going away.
void deleteSelection (in short action)
 DeleteSelection removes all nodes in the current selection.
void resetModificationCount ()
 to be used ONLY when we need to override the doc's modification state (such as when it's saved).
long getModificationCount ()
 Gets the modification count of the document we are editing.
void incrementModificationCount (in long aModCount)
 called each time we modify the document.
void doTransaction (in nsITransaction txn)
 doTransaction() fires a transaction.
void enableUndo (in boolean enable)
 turn the undo system on or off
void undo (in unsigned long count)
 undo reverses the effects of the last Do operation, if Undo is enabled in the editor.
void canUndo (out boolean isEnabled, out boolean canUndo)
 returns state information about the undo system.
void redo (in unsigned long count)
 redo reverses the effects of the last Undo operation It is provided here so clients need no knowledge of whether the editor has a transaction manager or not.
void canRedo (out boolean isEnabled, out boolean canRedo)
 returns state information about the redo system.
void beginTransaction ()
 beginTransaction is a signal from the caller to the editor that the caller will execute multiple updates to the content tree that should be treated as a single logical operation, in the most efficient way possible.
void endTransaction ()
 endTransaction is a signal to the editor that the caller is finished updating the content model.
void beginPlaceHolderTransaction (in nsIAtom name)
void endPlaceHolderTransaction ()
boolean shouldTxnSetSelection ()
void setShouldTxnSetSelection (in boolean should)
 Set the flag that prevents insertElementTxn from changing the selection.
void cut ()
 cut the currently selected text, putting it into the OS clipboard What if no text is selected? What about mixed selections? What are the clipboard formats?
boolean canCut ()
 Can we cut? True if the doc is modifiable, and we have a non- collapsed selection.
void copy ()
 copy the currently selected text, putting it into the OS clipboard What if no text is selected? What about mixed selections? What are the clipboard formats?
boolean canCopy ()
 Can we copy? True if we have a non-collapsed selection.
void paste (in long aSelectionType)
 paste the text in the OS clipboard at the cursor position, replacing the selected text (if any)
boolean canPaste (in long aSelectionType)
 Can we paste? True if the doc is modifiable, and we have pasteable data in the clipboard.
void selectAll ()
 sets the document selection to the entire contents of the document
void beginningOfDocument ()
 sets the document selection to the beginning of the document
void endOfDocument ()
 sets the document selection to the end of the document
boolean canDrag (in nsIDOMEvent aEvent)
 canDrag decides if a drag should be started (for example, based on the current selection and mousepoint).
void doDrag (in nsIDOMEvent aEvent)
 doDrag transfers the relevant data (as appropriate) to a transferable so it can later be dropped.
void insertFromDrop (in nsIDOMEvent aEvent)
 insertFromDrop looks for a dragsession and inserts the relevant data in response to a drop.
void setAttribute (in nsIDOMElement aElement, in AString attributestr, in AString attvalue)
 setAttribute() sets the attribute of aElement.
boolean getAttributeValue (in nsIDOMElement aElement, in AString attributestr, out AString resultValue)
 getAttributeValue() retrieves the attribute's value for aElement.
void removeAttribute (in nsIDOMElement aElement, in AString aAttribute)
 removeAttribute() deletes aAttribute from the attribute list of aElement.
void cloneAttribute (in AString aAttribute, in nsIDOMNode aDestNode, in nsIDOMNode aSourceNode)
 cloneAttribute() copies the attribute from the source node to the destination node and delete those not in the source.
void cloneAttributes (in nsIDOMNode destNode, in nsIDOMNode sourceNode)
 cloneAttributes() is similar to nsIDOMNode::cloneNode(), it assures the attribute nodes of the destination are identical with the source node by copying all existing attributes from the source and deleting those not in the source.
nsIDOMNode createNode (in AString tag, in nsIDOMNode parent, in long position)
 createNode instantiates a new element of type aTag and inserts it into aParent at aPosition.
void insertNode (in nsIDOMNode node, in nsIDOMNode parent, in long aPosition)
 insertNode inserts aNode into aParent at aPosition.
void splitNode (in nsIDOMNode existingRightNode, in long offset, out nsIDOMNode newLeftNode)
 splitNode() creates a new node identical to an existing node, and split the contents between the two nodes
void joinNodes (in nsIDOMNode leftNode, in nsIDOMNode rightNode, in nsIDOMNode parent)
 joinNodes() takes 2 nodes and merge their content|children.
void deleteNode (in nsIDOMNode child)
 deleteNode removes aChild from aParent.
void markNodeDirty (in nsIDOMNode node)
 markNodeDirty() sets a special dirty attribute on the node.
void switchTextDirection ()
 Switches the editor element direction; from "Left-to-Right" to "Right-to-Left", and vice versa.
AString outputToString (in AString formatType, in unsigned long flags)
 Output methods: aFormatType is a mime type, like text/plain.
void outputToStream (in nsIOutputStream aStream, in AString formatType, in ACString charsetOverride, in unsigned long flags)
void addEditorObserver (in nsIEditorObserver observer)
 add an EditorObserver to the editors list of observers.
void removeEditorObserver (in nsIEditorObserver observer)
 Remove an EditorObserver from the editor's list of observers.
void addEditActionListener (in nsIEditActionListener listener)
 add an EditActionListener to the editors list of listeners.
void removeEditActionListener (in nsIEditActionListener listener)
 Remove an EditActionListener from the editor's list of listeners.
void addDocumentStateListener (in nsIDocumentStateListener listener)
 Add a DocumentStateListener to the editors list of doc state listeners.
void removeDocumentStateListener (in nsIDocumentStateListener listener)
 Remove a DocumentStateListener to the editors list of doc state listeners.
void dumpContentTree ()
 And a debug method -- show us what the tree looks like right now.
void debugDumpContent ()
 Dumps a text representation of the content tree to standard out.
void debugUnitTests (out long outNumTests, out long outNumTestsFailed)
void beginComposition (in nsTextEventReplyPtr aReply)
 beginComposition(nsTextEventReply* aReply) Handles the start of inline input composition.
void setCompositionString (in DOMString aCompositionString, in nsIPrivateTextRangeListPtr aTextRange, in nsTextEventReplyPtr aReply)
 setCompositionString() Sets the inline input composition string.
void endComposition ()
 endComposition() Handles the end of inline input composition.
void queryComposition (in nsTextEventReplyPtr aReply)
 queryComposition() Get the composition position
void forceCompositionEnd ()
 forceCompositionEnd() force the composition end
void getReconversionString (in nsReconversionEventReplyPtr aReply)
 getReconversionString() Get the reconvertion string
void notifyIMEOnFocus ()
 Notify for IME when the editor got focus.
void notifyIMEOnBlur ()
 Notify for IME when the editor lost focus.
void getQueryCaretRect (in nsQueryCaretRectEventReplyPtr aReply)
 getQueryCaretRect() Get the query caret rect

Static Public Member Functions

static nsresult GetTextNodeTag (nsAString &aOutString)
 return the string that represents text nodes in the content tree
static nsresult GetChildOffset (nsIDOMNode *aChild, nsIDOMNode *aParent, PRInt32 &aOffset)
 Set aOffset to the offset of aChild in aParent.
static nsresult GetNodeLocation (nsIDOMNode *aChild, nsCOMPtr< nsIDOMNode > *aParent, PRInt32 *aOffset)
 Set aParent to the parent of aChild.
static nsresult GetLengthOfDOMNode (nsIDOMNode *aNode, PRUint32 &aCount)
 returns the number of things inside aNode in the out-param aCount.
static PRBool NodeIsType (nsIDOMNode *aNode, nsIAtom *aTag)
 returns PR_TRUE if aNode is of the type implied by aTag
static PRBool NodeIsTypeString (nsIDOMNode *aNode, const nsAString &aTag)
static nsresult GetTagString (nsIDOMNode *aNode, nsAString &outString)
 from html rules code - migration in progress
static nsIAtomGetTag (nsIDOMNode *aNode)
static PRBool IsTextOrElementNode (nsIDOMNode *aNode)
static PRBool IsTextNode (nsIDOMNode *aNode)
static PRInt32 GetIndexOf (nsIDOMNode *aParent, nsIDOMNode *aChild)
static nsCOMPtr< nsIDOMNodeGetChildAt (nsIDOMNode *aParent, PRInt32 aOffset)
static nsresult GetStartNodeAndOffset (nsISelection *aSelection, nsCOMPtr< nsIDOMNode > *outStartNode, PRInt32 *outStartOffset)
static nsresult GetEndNodeAndOffset (nsISelection *aSelection, nsCOMPtr< nsIDOMNode > *outEndNode, PRInt32 *outEndOffset)

Public Attributes

const short eNone = 0
const short eNext = 1
const short ePrevious = 2
const short eNextWord = 3
const short ePreviousWord = 4
const short eToBeginningOfLine = 5
const short eToEndOfLine = 6
readonly attribute nsISelection selection
attribute unsigned long flags
 edit flags for this editor.
attribute string contentsMIMEType
 the MimeType of the document
readonly attribute boolean isDocumentEditable
 Returns true if we have a document that is not marked read-only.
readonly attribute nsIDOMDocument document
 the DOM Document this editor is associated with, refcounted.
readonly attribute nsIDOMElement rootElement
 the body element, i.e.
readonly attribute
nsISelectionController 
selectionController
 the selection controller for the current presentation, refcounted.
readonly attribute boolean documentIsEmpty
 Returns true if the document has no meaningful content.
readonly attribute boolean documentModified
 Returns true if the document is modifed and needs saving.
attribute ACString documentCharacterSet
 Sets the current 'Save' document character set.
readonly attribute
nsITransactionManager 
transactionManager
 transactionManager Get the transaction manager the editor is using.
readonly attribute
nsIInlineSpellChecker 
inlineSpellChecker
readonly attribute DOMString phonetic
 phonetic get the phonetic value of the input text

Static Public Attributes

static nsIAtomgTypingTxnName
static nsIAtomgIMETxnName
static nsIAtomgDeleteTxnName

Protected Types

enum  TDocumentListenerNotification { eDocumentCreated, eDocumentToBeDestroyed, eDocumentStateChanged }
enum  Tristate { eTriUnset, eTriFalse, eTriTrue }

Protected Member Functions

NS_IMETHOD CreateTxnForSetAttribute (nsIDOMElement *aElement, const nsAString &aAttribute, const nsAString &aValue, ChangeAttributeTxn **aTxn)
 create a transaction for setting aAttribute to aValue on aElement
NS_IMETHOD CreateTxnForRemoveAttribute (nsIDOMElement *aElement, const nsAString &aAttribute, ChangeAttributeTxn **aTxn)
 create a transaction for removing aAttribute on aElement
NS_IMETHOD CreateTxnForCreateElement (const nsAString &aTag, nsIDOMNode *aParent, PRInt32 aPosition, CreateElementTxn **aTxn)
 create a transaction for creating a new child node of aParent of type aTag.
NS_IMETHOD CreateTxnForInsertElement (nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aOffset, InsertElementTxn **aTxn)
 create a transaction for inserting aNode as a child of aParent.
NS_IMETHOD CreateTxnForDeleteElement (nsIDOMNode *aElement, DeleteElementTxn **aTxn)
 create a transaction for removing aElement from its parent.
NS_IMETHOD CreateTxnForDeleteSelection (EDirection aAction, EditAggregateTxn **aTxn)
NS_IMETHOD CreateTxnForDeleteInsertionPoint (nsIDOMRange *aRange, EDirection aAction, EditAggregateTxn *aTxn)
NS_IMETHOD CreateTxnForInsertText (const nsAString &aStringToInsert, nsIDOMCharacterData *aTextNode, PRInt32 aOffset, InsertTextTxn **aTxn)
 create a transaction for inserting aStringToInsert into aTextNode if aTextNode is null, the string is inserted at the current selection.
NS_IMETHOD CreateTxnForIMEText (const nsAString &aStringToInsert, IMETextTxn **aTxn)
NS_IMETHOD CreateTxnForAddStyleSheet (nsICSSStyleSheet *aSheet, AddStyleSheetTxn **aTxn)
 create a transaction for adding a style sheet
NS_IMETHOD CreateTxnForRemoveStyleSheet (nsICSSStyleSheet *aSheet, RemoveStyleSheetTxn **aTxn)
 create a transaction for removing a style sheet
NS_IMETHOD DeleteText (nsIDOMCharacterData *aElement, PRUint32 aOffset, PRUint32 aLength)
NS_IMETHOD CreateTxnForDeleteText (nsIDOMCharacterData *aElement, PRUint32 aOffset, PRUint32 aLength, DeleteTextTxn **aTxn)
NS_IMETHOD CreateTxnForSplitNode (nsIDOMNode *aNode, PRUint32 aOffset, SplitElementTxn **aTxn)
NS_IMETHOD CreateTxnForJoinNode (nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, JoinElementTxn **aTxn)
NS_IMETHOD DeleteSelectionAndPrepareToCreateNode (nsCOMPtr< nsIDOMNode > &parentSelectedNode, PRInt32 &offsetOfNewNode)
NS_IMETHOD DoAfterDoTransaction (nsITransaction *aTxn)
NS_IMETHOD DoAfterUndoTransaction ()
NS_IMETHOD DoAfterRedoTransaction ()
NS_IMETHOD NotifyDocumentListeners (TDocumentListenerNotification aNotificationType)
NS_IMETHOD SelectEntireDocument (nsISelection *aSelection)
 make the given selection span the entire document
NS_IMETHOD GetWrapWidth (PRInt32 *aWrapCol)
NS_IMETHOD ScrollSelectionIntoView (PRBool aScrollToAnchor)
 helper method for scrolling the selection into view after an edit operation.
virtual PRBool IsBlockNode (nsIDOMNode *aNode)
nsresult GetPriorNodeImpl (nsIDOMNode *aCurrentNode, PRBool aEditableNode, nsCOMPtr< nsIDOMNode > *aResultNode, PRBool bNoBlockCrossing=PR_FALSE)
nsresult GetNextNodeImpl (nsIDOMNode *aCurrentNode, PRBool aEditableNode, nsCOMPtr< nsIDOMNode > *aResultNode, PRBool bNoBlockCrossing=PR_FALSE)
nsresult GetKBStateControl (nsIKBStateControl **aKBSC)
nsresult InstallEventListeners ()
virtual nsresult CreateEventListeners ()=0
virtual void RemoveEventListeners ()
PRBool GetDesiredSpellCheckState ()
 Return true if spellchecking should be enabled for this editor.

Protected Attributes

nsCString mContentMIMEType
PRUint32 mModCount
PRUint32 mFlags
nsWeakPtr mPresShellWeak
nsWeakPtr mSelConWeak
nsIViewManagermViewManager
PRInt32 mUpdateCount
enum nsEditor::Tristate mSpellcheckCheckboxState
nsCOMPtr< nsIInlineSpellCheckermInlineSpellChecker
nsCOMPtr< nsITransactionManagermTxnMgr
nsWeakPtr mPlaceHolderTxn
nsIAtommPlaceHolderName
PRInt32 mPlaceHolderBatch
nsSelectionStatemSelState
nsSelectionState mSavedSel
nsRangeUpdater mRangeUpdater
nsCOMPtr< nsIDOMElementmRootElement
PRInt32 mAction
EDirection mDirection
nsIPrivateTextRangeListmIMETextRangeList
nsCOMPtr< nsIDOMCharacterDatamIMETextNode
PRUint32 mIMETextOffset
PRUint32 mIMEBufferLength
PRPackedBool mInIMEMode
PRPackedBool mIsIMEComposing
PRPackedBool mNeedRecoverIMEOpenState
PRPackedBool mShouldTxnSetSelection
PRPackedBool mDidPreDestroy
nsVoidArraymActionListeners
nsVoidArraymEditorObservers
nsCOMPtr< nsISupportsArraymDocStateListeners
PRInt8 mDocDirtyState
nsWeakPtr mDocWeak
nsCOMPtr< nsIDOMEventReceivermDOMEventReceiver
nsCOMPtr< nsIDTDmDTD
nsStringmPhonetic
nsCOMPtr< nsIDOMEventListenermKeyListenerP
nsCOMPtr< nsIDOMEventListenermMouseListenerP
nsCOMPtr< nsIDOMEventListenermTextListenerP
nsCOMPtr< nsIDOMEventListenermCompositionListenerP
nsCOMPtr< nsIDOMEventListenermDragListenerP
nsCOMPtr< nsIDOMEventListenermFocusListenerP

Friends

class nsAutoTxnsConserveSelection
class nsAutoSelectionReset
class nsAutoRules
class nsRangeUpdater
PRBool NSCanUnload (nsISupports *serviceMgr)

Detailed Description

implementation of an editor object.

it will be the controller/focal point for the main editor services. i.e. the GUIManager, publishing, transaction manager, event interfaces. the idea for the event interfaces is to have them delegate the actual commands to the editor independent of the XPFE implementation.

Definition at line 98 of file nsEditor.h.


Member Typedef Documentation

typedef short nsIEditor::EDirection [inherited]

Definition at line 71 of file nsIEditor.idl.


Member Enumeration Documentation

Enumerator:
kIterForward 
kIterBackward 

Definition at line 105 of file nsEditor.h.

Enumerator:
kOpIgnore 
kOpNone 
kOpUndo 
kOpRedo 
kOpInsertNode 
kOpCreateNode 
kOpDeleteNode 
kOpSplitNode 
kOpJoinNode 
kOpDeleteSelection 
kOpInsertBreak 
kOpInsertText 
kOpInsertIMEText 
kOpDeleteText 

Reimplemented in nsHTMLEditor.

Definition at line 111 of file nsEditor.h.

Enumerator:
eDocumentCreated 
eDocumentToBeDestroyed 
eDocumentStateChanged 

Definition at line 292 of file nsEditor.h.

enum nsEditor::Tristate [protected]
Enumerator:
eTriUnset 
eTriFalse 
eTriTrue 

Definition at line 601 of file nsEditor.h.


Constructor & Destructor Documentation

The default constructor.

This should suffice. the setting of the interfaces is done after the construction of the editor class.

Definition at line 145 of file nsEditor.cpp.

Here is the call graph for this function:

nsEditor::~nsEditor ( ) [virtual]

The default destructor.

This should suffice. Should this be pure virtual for someone to derive from the nsEditor later? I dont believe so.

Definition at line 189 of file nsEditor.cpp.

{
  /* first, delete the transaction manager if there is one.
     this will release any remaining transactions.
     this is important because transactions can hold onto the atoms (gTypingTxnName, ...)
     and to make the optimization (holding refcounted statics) work correctly, 
     the editor instance needs to hold the last refcount.
     If you get this wrong, expect to deref a garbage gTypingTxnName pointer if you bring up a second editor.
  */
  if (mTxnMgr) { 
    mTxnMgr = 0;
  }
  nsrefcnt refCount=0;
  if (gTypingTxnName)  // we addref'd in the constructor
  { // want to release it without nulling out the pointer.
    refCount = gTypingTxnName->Release();
    if (0==refCount) {
      gTypingTxnName = nsnull; 
    }
  }

  if (gIMETxnName)  // we addref'd in the constructor
  { // want to release it without nulling out the pointer.
    refCount = gIMETxnName->Release();
    if (0==refCount) {
      gIMETxnName = nsnull;
    }
  }

  if (gDeleteTxnName)  // we addref'd in the constructor
  { // want to release it without nulling out the pointer.
    refCount = gDeleteTxnName->Release();
    if (0==refCount) {
      gDeleteTxnName = nsnull;
    }
  }

  delete mEditorObservers;   // no need to release observers; we didn't addref them
  mEditorObservers = 0;
  
  if (mActionListeners)
  {
    PRInt32 i;
    nsIEditActionListener *listener;

    for (i = 0; i < mActionListeners->Count(); i++)
    {
      listener = (nsIEditActionListener *)mActionListeners->ElementAt(i);
      NS_IF_RELEASE(listener);
    }

    delete mActionListeners;
    mActionListeners = 0;
  }

  /* shut down all classes that needed initialization */
  InsertTextTxn::ClassShutdown();
  IMETextTxn::ClassShutdown();

  delete mPhonetic;
 
  NS_IF_RELEASE(mViewManager);
}

Here is the call graph for this function:


Member Function Documentation

Add a DocumentStateListener to the editors list of doc state listeners.

add an EditActionListener to the editors list of listeners.

add an EditorObserver to the editors list of observers.

Definition at line 5437 of file nsEditor.cpp.

{
  if (!aNode) return NS_ERROR_NULL_POINTER;
  nsCOMPtr<nsISelection> selection;
  nsresult res = GetSelection(getter_AddRefs(selection));
  if (NS_FAILED(res)) return res;
  if(!selection) return NS_ERROR_FAILURE;

  nsCOMPtr<nsIDOMNode> parentNode;
  res = aNode->GetParentNode(getter_AddRefs(parentNode));
  if (NS_FAILED(res)) return res;
  if (!parentNode) return NS_ERROR_NULL_POINTER;
  
  PRInt32 offset;
  res = GetChildOffset(aNode, parentNode, offset);
  if (NS_FAILED(res)) return res;
  
  nsCOMPtr<nsIDOMRange> range;
  res = CreateRange(parentNode, offset, parentNode, offset+1, getter_AddRefs(range));
  if (NS_FAILED(res)) return res;
  if (!range) return NS_ERROR_NULL_POINTER;

  return selection->AddRange(range);
}

Here is the call graph for this function:

Here is the caller graph for this function:

routines for managing the preservation of selection across various editor actions

Definition at line 2105 of file nsEditor.cpp.

{
  return !(mSavedSel.IsEmpty());
}

Here is the call graph for this function:

Here is the caller graph for this function:

beginComposition(nsTextEventReply* aReply) Handles the start of inline input composition.

sets the document selection to the beginning of the document

beginTransaction is a signal from the caller to the editor that the caller will execute multiple updates to the content tree that should be treated as a single logical operation, in the most efficient way possible.


All transactions executed between a call to beginTransaction and endTransaction will be undoable as an atomic action.
endTransaction must be called after beginTransaction.
Calls to beginTransaction can be nested, as long as endTransaction is called once per beginUpdate.

Definition at line 4603 of file nsEditor.cpp.

{
  NS_PRECONDITION(mUpdateCount >= 0, "bad state");


  if (0 == mUpdateCount)
  {
    // Turn off selection updates and notifications.

    nsCOMPtr<nsISelection> selection;
    GetSelection(getter_AddRefs(selection));

    if (selection) 
    {
      nsCOMPtr<nsISelectionPrivate> selPrivate(do_QueryInterface(selection));
      selPrivate->StartBatchChanges();
    }

    // Turn off view updating.

    if (mViewManager)
      mViewManager->BeginUpdateViewBatch();

    // Turn off reflow.

    nsCOMPtr<nsIPresShell> presShell;
    GetPresShell(getter_AddRefs(presShell));

    if (presShell)
      presShell->BeginReflowBatching();
  }

  mUpdateCount++;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsEditor::CanContainTag ( nsIDOMNode aParent,
const nsAString &  aTag 
)

returns PR_TRUE if aParent can contain a child of type aTag

Definition at line 3947 of file nsEditor.cpp.

{
  nsCOMPtr<nsIDOMElement> parentElement = do_QueryInterface(aParent);
  if (!parentElement) return PR_FALSE;
  
  nsAutoString parentStringTag;
  parentElement->GetTagName(parentStringTag);
  return TagCanContainTag(parentStringTag, aChildTag);
}

Here is the call graph for this function:

Here is the caller graph for this function:

boolean nsIEditor::canCopy ( ) [inherited]

Can we copy? True if we have a non-collapsed selection.

boolean nsIEditor::canCut ( ) [inherited]

Can we cut? True if the doc is modifiable, and we have a non- collapsed selection.

boolean nsIEditor::canDrag ( in nsIDOMEvent  aEvent) [inherited]

canDrag decides if a drag should be started (for example, based on the current selection and mousepoint).

boolean nsIEditor::canPaste ( in long  aSelectionType) [inherited]

Can we paste? True if the doc is modifiable, and we have pasteable data in the clipboard.

void nsIEditor::canRedo ( out boolean  isEnabled,
out boolean  canRedo 
) [inherited]

returns state information about the redo system.

Parameters:
aIsEnabled[OUT] PR_TRUE if redo is enabled
aCanRedo[OUT] PR_TRUE if at least one transaction is currently ready to be redone.
void nsIEditor::canUndo ( out boolean  isEnabled,
out boolean  canUndo 
) [inherited]

returns state information about the undo system.

Parameters:
aIsEnabled[OUT] PR_TRUE if undo is enabled
aCanUndo[OUT] PR_TRUE if at least one transaction is currently ready to be undone.

Definition at line 5462 of file nsEditor.cpp.

{
  nsCOMPtr<nsISelection> selection;
  nsresult res = nsEditor::GetSelection(getter_AddRefs(selection));
  if (NS_FAILED(res)) return res;
  if (!selection) return NS_ERROR_FAILURE;
  return selection->RemoveAllRanges();  
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIEditor::cloneAttribute ( in AString  aAttribute,
in nsIDOMNode  aDestNode,
in nsIDOMNode  aSourceNode 
) [inherited]

cloneAttribute() copies the attribute from the source node to the destination node and delete those not in the source.

The supplied nodes MUST BE ELEMENTS (most callers are working with nodes)

Parameters:
aAttributethe name of the attribute to copy
aDestNodethe destination element to operate on
aSourceNodethe source element to copy attributes from
Exceptions:
NS_ERROR_NULL_POINTERat least one of the nodes is null
NS_ERROR_NO_INTERFACEat least one of the nodes is not an element
void nsIEditor::cloneAttributes ( in nsIDOMNode  destNode,
in nsIDOMNode  sourceNode 
) [inherited]

cloneAttributes() is similar to nsIDOMNode::cloneNode(), it assures the attribute nodes of the destination are identical with the source node by copying all existing attributes from the source and deleting those not in the source.

This is used when the destination node (element) already exists

The supplied nodes MUST BE ELEMENTS (most callers are working with nodes)

Parameters:
aDestNodethe destination element to operate on
aSourceNodethe source element to copy attributes from
void nsIEditor::copy ( ) [inherited]

copy the currently selected text, putting it into the OS clipboard What if no text is selected? What about mixed selections? What are the clipboard formats?

counts number of editable child nodes

Definition at line 4131 of file nsEditor.cpp.

{
  outCount = 0;
  if (!aNode) { return NS_ERROR_NULL_POINTER; }
  nsresult res=NS_OK;
  PRBool hasChildNodes;
  aNode->HasChildNodes(&hasChildNodes);
  if (hasChildNodes)
  {
    nsCOMPtr<nsIDOMNodeList>nodeList;
    res = aNode->GetChildNodes(getter_AddRefs(nodeList));
    if (NS_SUCCEEDED(res) && nodeList) 
    {
      PRUint32 i;
      PRUint32 len;
      nodeList->GetLength(&len);
      for (i=0 ; i<len; i++)
      {
        nsCOMPtr<nsIDOMNode> child;
        res = nodeList->Item((PRInt32)i, getter_AddRefs(child));
        if ((NS_SUCCEEDED(res)) && (child))
        {
          if (IsEditable(child))
          {
            outCount++;
          }
        }
      }
    }
    else if (!nodeList)
      res = NS_ERROR_NULL_POINTER;
  }
  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual nsresult nsEditor::CreateEventListeners ( ) [protected, pure virtual]

Implemented in nsHTMLEditor, and nsPlaintextEditor.

nsresult nsEditor::CreateHTMLContent ( const nsAString &  aTag,
nsIContent **  aContent 
)

Definition at line 5472 of file nsEditor.cpp.

{
  nsCOMPtr<nsIDOMDocument> tempDoc;
  GetDocument(getter_AddRefs(tempDoc));

  nsCOMPtr<nsIDocument> doc = do_QueryInterface(tempDoc);
  if (!doc)
    return NS_ERROR_FAILURE;

  // XXX Wallpaper over editor bug (editor tries to create elements with an
  //     empty nodename).
  if (aTag.IsEmpty()) {
    NS_ERROR("Don't pass an empty tag to nsEditor::CreateHTMLContent, "
             "check caller.");
    return NS_ERROR_FAILURE;
  }

  nsCOMPtr<nsIAtom> tag = do_GetAtom(aTag);
  if (!tag)
    return NS_ERROR_OUT_OF_MEMORY;

  nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(tempDoc);
  if (htmlDoc) {
      return doc->CreateElem(tag, nsnull, doc->GetDefaultNamespaceID(),
                             PR_TRUE, aContent);
  }

  return doc->CreateElem(tag, nsnull, kNameSpaceID_XHTML, PR_FALSE, aContent);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIDOMNode nsIEditor::createNode ( in AString  tag,
in nsIDOMNode  parent,
in long  position 
) [inherited]

createNode instantiates a new element of type aTag and inserts it into aParent at aPosition.

Parameters:
aTagThe type of object to create
aParentThe node to insert the new object into
aPositionThe place in aParent to insert the new node
Returns:
The node created. Caller must release aNewNode.
nsresult nsEditor::CreateRange ( nsIDOMNode aStartParent,
PRInt32  aStartOffset,
nsIDOMNode aEndParent,
PRInt32  aEndOffset,
nsIDOMRange **  aRange 
)

Definition at line 5411 of file nsEditor.cpp.

{
  nsresult result;
  result = CallCreateInstance("@mozilla.org/content/range;1", aRange);
  if (NS_FAILED(result))
    return result;

  if (!*aRange)
    return NS_ERROR_NULL_POINTER;

  result = (*aRange)->SetStart(aStartParent, aStartOffset);

  if (NS_SUCCEEDED(result))
    result = (*aRange)->SetEnd(aEndParent, aEndOffset);

  if (NS_FAILED(result))
  {
    NS_RELEASE((*aRange));
    *aRange = 0;
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

create a transaction for adding a style sheet

Definition at line 5127 of file nsEditor.cpp.

{
  nsresult rv = TransactionFactory::GetNewTransaction(AddStyleSheetTxn::GetCID(), (EditTxn **)aTxn);
  if (NS_FAILED(rv))
    return rv;
    
  if (! *aTxn)
    return NS_ERROR_OUT_OF_MEMORY;

  return (*aTxn)->Init(this, aSheet);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsEditor::CreateTxnForCreateElement ( const nsAString &  aTag,
nsIDOMNode aParent,
PRInt32  aPosition,
CreateElementTxn **  aTxn 
) [protected]

create a transaction for creating a new child node of aParent of type aTag.

Definition at line 5019 of file nsEditor.cpp.

{
  nsresult result = NS_ERROR_NULL_POINTER;
  if (nsnull != aParent)
  {
    result = TransactionFactory::GetNewTransaction(CreateElementTxn::GetCID(), (EditTxn **)aTxn);
    if (NS_SUCCEEDED(result))  {
      result = (*aTxn)->Init(this, aTag, aParent, aPosition);
    }
  }
  return result;
}

Here is the call graph for this function:

create a transaction for removing aElement from its parent.

Definition at line 5052 of file nsEditor.cpp.

{
  nsresult result = NS_ERROR_NULL_POINTER;
  if (nsnull != aElement)
  {
    result = TransactionFactory::GetNewTransaction(DeleteElementTxn::GetCID(), (EditTxn **)aTxn);
    if (NS_SUCCEEDED(result)) {
      result = (*aTxn)->Init(aElement, &mRangeUpdater);
    }
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 5233 of file nsEditor.cpp.

{
  // get the node and offset of the insertion point
  nsCOMPtr<nsIDOMNode> node;
  nsresult result = aRange->GetStartContainer(getter_AddRefs(node));
  if (NS_FAILED(result))
    return result;

  PRInt32 offset;
  result = aRange->GetStartOffset(&offset);
  if (NS_FAILED(result))
    return result;

  // determine if the insertion point is at the beginning, middle, or end of the node
  nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(node);

  PRUint32 count=0;

  if (nodeAsText)
    nodeAsText->GetLength(&count);
  else
  { 
    // get the child list and count
    nsCOMPtr<nsIDOMNodeList>childList;
    result = node->GetChildNodes(getter_AddRefs(childList));
    if ((NS_SUCCEEDED(result)) && childList)
      childList->GetLength(&count);
  }

  PRBool isFirst = (0 == offset);
  PRBool isLast  = (count == (PRUint32)offset);

  // XXX: if isFirst && isLast, then we'll need to delete the node 
  //      as well as the 1 child

  // build a transaction for deleting the appropriate data
  // XXX: this has to come from rule section
  if ((ePrevious==aAction) && (PR_TRUE==isFirst))
  { // we're backspacing from the beginning of the node.  Delete the first thing to our left
    nsCOMPtr<nsIDOMNode> priorNode;
    result = GetPriorNode(node, PR_TRUE, address_of(priorNode));
    if ((NS_SUCCEEDED(result)) && priorNode)
    { // there is a priorNode, so delete it's last child (if text content, delete the last char.)
      // if it has no children, delete it
      nsCOMPtr<nsIDOMCharacterData> priorNodeAsText = do_QueryInterface(priorNode);
      if (priorNodeAsText)
      {
        PRUint32 length=0;
        priorNodeAsText->GetLength(&length);
        if (0<length)
        {
          DeleteTextTxn *txn;
          result = CreateTxnForDeleteText(priorNodeAsText, length-1, 1, &txn);
          if (NS_SUCCEEDED(result)) {
            aTxn->AppendChild(txn);
            NS_RELEASE(txn);
          }
        }
        else
        { // XXX: can you have an empty text node?  If so, what do you do?
          printf("ERROR: found a text node with 0 characters\n");
          result = NS_ERROR_UNEXPECTED;
        }
      }
      else
      { // priorNode is not text, so tell it's parent to delete it
        DeleteElementTxn *txn;
        result = CreateTxnForDeleteElement(priorNode, &txn);
        if (NS_SUCCEEDED(result)) {
          aTxn->AppendChild(txn);
          NS_RELEASE(txn);
        }
      }
    }
  }
  else if ((nsIEditor::eNext==aAction) && (PR_TRUE==isLast))
  { // we're deleting from the end of the node.  Delete the first thing to our right
    nsCOMPtr<nsIDOMNode> nextNode;
    result = GetNextNode(node, PR_TRUE, address_of(nextNode));
    if ((NS_SUCCEEDED(result)) && nextNode)
    { // there is a nextNode, so delete it's first child (if text content, delete the first char.)
      // if it has no children, delete it
      nsCOMPtr<nsIDOMCharacterData> nextNodeAsText = do_QueryInterface(nextNode);
      if (nextNodeAsText)
      {
        PRUint32 length=0;
        nextNodeAsText->GetLength(&length);
        if (0<length)
        {
          DeleteTextTxn *txn;
          result = CreateTxnForDeleteText(nextNodeAsText, 0, 1, &txn);
          if (NS_SUCCEEDED(result)) {
            aTxn->AppendChild(txn);
            NS_RELEASE(txn);
          }
        }
        else
        { // XXX: can you have an empty text node?  If so, what do you do?
          printf("ERROR: found a text node with 0 characters\n");
          result = NS_ERROR_UNEXPECTED;
        }
      }
      else
      { // nextNode is not text, so tell it's parent to delete it
        DeleteElementTxn *txn;
        result = CreateTxnForDeleteElement(nextNode, &txn);
        if (NS_SUCCEEDED(result)) {
          aTxn->AppendChild(txn);
          NS_RELEASE(txn);
        }
      }
    }
  }
  else
  {
    if (nodeAsText)
    { // we have text, so delete a char at the proper offset
      if (nsIEditor::ePrevious==aAction) {
        offset --;
      }
      DeleteTextTxn *txn;
      result = CreateTxnForDeleteText(nodeAsText, offset, 1, &txn);
      if (NS_SUCCEEDED(result)) {
        aTxn->AppendChild(txn);
        NS_RELEASE(txn);
      }
    }
    else
    { // we're either deleting a node or some text, need to dig into the next/prev node to find out
      nsCOMPtr<nsIDOMNode> selectedNode;
      if (ePrevious==aAction)
      {
        result = GetPriorNode(node, offset, PR_TRUE, address_of(selectedNode));
      }
      else if (eNext==aAction)
      {
        result = GetNextNode(node, offset, PR_TRUE, address_of(selectedNode));
      }
      if (NS_FAILED(result)) { return result; }
      if (selectedNode) 
      {
        nsCOMPtr<nsIDOMCharacterData> selectedNodeAsText =
                                             do_QueryInterface(selectedNode);
        if (selectedNodeAsText)
        { // we are deleting from a text node, so do a text deletion
          PRInt32 begin = 0;    // default for forward delete
          if (ePrevious==aAction)
          {
            PRUint32 length=0;
            selectedNodeAsText->GetLength(&length);
            if (0<length)
              begin = length-1;
          }
          DeleteTextTxn *delTextTxn;
          result = CreateTxnForDeleteText(selectedNodeAsText, begin, 1, &delTextTxn);
          if (NS_FAILED(result))  { return result; }
          if (!delTextTxn) { return NS_ERROR_NULL_POINTER; }
          aTxn->AppendChild(delTextTxn);
          NS_RELEASE(delTextTxn);
        }
        else
        {
          DeleteElementTxn *delElementTxn;
          result = CreateTxnForDeleteElement(selectedNode, &delElementTxn);
          if (NS_FAILED(result))  { return result; }
          if (!delElementTxn) { return NS_ERROR_NULL_POINTER; }
          aTxn->AppendChild(delElementTxn);
          NS_RELEASE(delElementTxn);
        }
      }
    }
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 5156 of file nsEditor.cpp.

{
  if (!aTxn)
    return NS_ERROR_NULL_POINTER;
  *aTxn = nsnull;

#ifdef DEBUG_akkana
  NS_ASSERTION(aAction != eNextWord && aAction != ePreviousWord && aAction != eToEndOfLine, "CreateTxnForDeleteSelection: unsupported action!");
#endif

  nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mSelConWeak);
  if (!selCon) return NS_ERROR_NOT_INITIALIZED;
  nsCOMPtr<nsISelection> selection;
  nsresult result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
                                         getter_AddRefs(selection));
  if ((NS_SUCCEEDED(result)) && selection)
  {
    // Check whether the selection is collapsed and we should do nothing:
    PRBool isCollapsed;
    result = (selection->GetIsCollapsed(&isCollapsed));
    if (NS_SUCCEEDED(result) && isCollapsed && aAction == eNone)
      return NS_OK;

    // allocate the out-param transaction
    result = TransactionFactory::GetNewTransaction(EditAggregateTxn::GetCID(), (EditTxn **)aTxn);
    if (NS_FAILED(result)) {
      return result;
    }

    nsCOMPtr<nsISelectionPrivate>selPrivate(do_QueryInterface(selection));
    nsCOMPtr<nsIEnumerator> enumerator;
    result = selPrivate->GetEnumerator(getter_AddRefs(enumerator));
    if (NS_SUCCEEDED(result) && enumerator)
    {
      for (enumerator->First(); NS_OK!=enumerator->IsDone(); enumerator->Next())
      {
        nsCOMPtr<nsISupports> currentItem;
        result = enumerator->CurrentItem(getter_AddRefs(currentItem));
        if ((NS_SUCCEEDED(result)) && (currentItem))
        {
          nsCOMPtr<nsIDOMRange> range( do_QueryInterface(currentItem) );
          range->GetCollapsed(&isCollapsed);
          if (!isCollapsed)
          {
            DeleteRangeTxn *txn;
            result = TransactionFactory::GetNewTransaction(DeleteRangeTxn::GetCID(), (EditTxn **)&txn);
            if (NS_SUCCEEDED(result) && txn)
            {
              txn->Init(this, range, &mRangeUpdater);
              (*aTxn)->AppendChild(txn);
              NS_RELEASE(txn);
            }
            else
              result = NS_ERROR_OUT_OF_MEMORY;
          }
          else
          { // we have an insertion point.  delete the thing in front of it or behind it, depending on aAction
            result = CreateTxnForDeleteInsertionPoint(range, aAction, *aTxn);
          }
        }
      }
    }
  }

  // if we didn't build the transaction correctly, destroy the out-param transaction so we don't leak it.
  if (NS_FAILED(result))
  {
    NS_IF_RELEASE(*aTxn);
  }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsEditor::CreateTxnForDeleteText ( nsIDOMCharacterData aElement,
PRUint32  aOffset,
PRUint32  aLength,
DeleteTextTxn **  aTxn 
) [protected]

Definition at line 3106 of file nsEditor.cpp.

{
  if (!aElement)
    return NS_ERROR_NULL_POINTER;

  nsresult result = TransactionFactory::GetNewTransaction(DeleteTextTxn::GetCID(), (EditTxn **)aTxn);
  if (NS_SUCCEEDED(result))  {
    result = (*aTxn)->Init(this, aElement, aOffset, aLength, &mRangeUpdater);
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsEditor::CreateTxnForIMEText ( const nsAString &  aStringToInsert,
IMETextTxn **  aTxn 
) [protected]

Definition at line 5107 of file nsEditor.cpp.

{
  NS_ASSERTION(aTxn, "illegal value- null ptr- aTxn");
  if(!aTxn) return NS_ERROR_NULL_POINTER;
     
  nsresult  result;

  result = TransactionFactory::GetNewTransaction(IMETextTxn::GetCID(), (EditTxn **)aTxn);
  if (nsnull!=*aTxn) {
    result = (*aTxn)->Init(mIMETextNode,mIMETextOffset,mIMEBufferLength,mIMETextRangeList,aStringToInsert,mSelConWeak);
  }
  else {
    result = NS_ERROR_OUT_OF_MEMORY;
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsEditor::CreateTxnForInsertElement ( nsIDOMNode aNode,
nsIDOMNode aParent,
PRInt32  aOffset,
InsertElementTxn **  aTxn 
) [protected]

create a transaction for inserting aNode as a child of aParent.

Definition at line 5036 of file nsEditor.cpp.

{
  nsresult result = NS_ERROR_NULL_POINTER;
  if (aNode && aParent && aTxn)
  {
    result = TransactionFactory::GetNewTransaction(InsertElementTxn::GetCID(), (EditTxn **)aTxn);
    if (NS_SUCCEEDED(result)) {
      result = (*aTxn)->Init(aNode, aParent, aPosition, this);
    }
  }
  return result;
}

Here is the call graph for this function:

NS_IMETHODIMP nsEditor::CreateTxnForInsertText ( const nsAString &  aStringToInsert,
nsIDOMCharacterData aTextNode,
PRInt32  aOffset,
InsertTextTxn **  aTxn 
) [protected]

create a transaction for inserting aStringToInsert into aTextNode if aTextNode is null, the string is inserted at the current selection.

Definition at line 3050 of file nsEditor.cpp.

{
  if (!aTextNode || !aTxn) return NS_ERROR_NULL_POINTER;
  nsresult result;

  result = TransactionFactory::GetNewTransaction(InsertTextTxn::GetCID(), (EditTxn **)aTxn);
  if (NS_FAILED(result)) return result;
  if (!*aTxn) return NS_ERROR_OUT_OF_MEMORY;
  result = (*aTxn)->Init(aTextNode, aOffset, aStringToInsert, this);
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsEditor::CreateTxnForJoinNode ( nsIDOMNode aLeftNode,
nsIDOMNode aRightNode,
JoinElementTxn **  aTxn 
) [protected]

Definition at line 3138 of file nsEditor.cpp.

{
  if (!aLeftNode || !aRightNode)
    return NS_ERROR_NULL_POINTER;

  nsresult result = TransactionFactory::GetNewTransaction(JoinElementTxn::GetCID(), (EditTxn **)aTxn);
  if (NS_SUCCEEDED(result))  {
    result = (*aTxn)->Init(this, aLeftNode, aRightNode);
  }
  return result;
}

Here is the call graph for this function:

NS_IMETHODIMP nsEditor::CreateTxnForRemoveAttribute ( nsIDOMElement aElement,
const nsAString &  aAttribute,
ChangeAttributeTxn **  aTxn 
) [protected]

create a transaction for removing aAttribute on aElement

Definition at line 5001 of file nsEditor.cpp.

{
  nsresult result = NS_ERROR_NULL_POINTER;
  if (nsnull != aElement)
  {
    result = TransactionFactory::GetNewTransaction(ChangeAttributeTxn::GetCID(), (EditTxn **)aTxn);
    if (NS_SUCCEEDED(result))  
    {
      nsAutoString value;
      result = (*aTxn)->Init(this, aElement, aAttribute, value, PR_TRUE);
    }
  }
  return result;
}

Here is the call graph for this function:

create a transaction for removing a style sheet

Definition at line 5142 of file nsEditor.cpp.

{
  nsresult rv = TransactionFactory::GetNewTransaction(RemoveStyleSheetTxn::GetCID(), (EditTxn **)aTxn);
  if (NS_FAILED(rv))
    return rv;
    
  if (! *aTxn)
    return NS_ERROR_OUT_OF_MEMORY;

  return (*aTxn)->Init(this, aSheet);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsEditor::CreateTxnForSetAttribute ( nsIDOMElement aElement,
const nsAString &  aAttribute,
const nsAString &  aValue,
ChangeAttributeTxn **  aTxn 
) [protected]

create a transaction for setting aAttribute to aValue on aElement

Definition at line 4983 of file nsEditor.cpp.

{
  nsresult result = NS_ERROR_NULL_POINTER;
  if (nsnull != aElement)
  {
    result = TransactionFactory::GetNewTransaction(ChangeAttributeTxn::GetCID(), (EditTxn **)aTxn);
    if (NS_SUCCEEDED(result))  {
      result = (*aTxn)->Init(this, aElement, aAttribute, aValue, PR_FALSE);
    }
  }
  return result;
}

Here is the call graph for this function:

NS_IMETHODIMP nsEditor::CreateTxnForSplitNode ( nsIDOMNode aNode,
PRUint32  aOffset,
SplitElementTxn **  aTxn 
) [protected]

Definition at line 3124 of file nsEditor.cpp.

{
  if (!aNode)
    return NS_ERROR_NULL_POINTER;

  nsresult result = TransactionFactory::GetNewTransaction(SplitElementTxn::GetCID(), (EditTxn **)aTxn);
  if (NS_FAILED(result))
    return result;

  return (*aTxn)->Init(this, aNode, aOffset);
}

Here is the call graph for this function:

void nsIEditor::cut ( ) [inherited]

cut the currently selected text, putting it into the OS clipboard What if no text is selected? What about mixed selections? What are the clipboard formats?

Dumps a text representation of the content tree to standard out.

void nsIEditor::debugUnitTests ( out long  outNumTests,
out long  outNumTestsFailed 
) [inherited]
void nsIEditor::deleteNode ( in nsIDOMNode  child) [inherited]

deleteNode removes aChild from aParent.

Parameters:
aChildThe node to delete
void nsIEditor::deleteSelection ( in short  action) [inherited]

DeleteSelection removes all nodes in the current selection.

Parameters:
aDirif eNext, delete to the right (for example, the DEL key) if ePrevious, delete to the left (for example, the BACKSPACE key)

Here is the caller graph for this function:

NS_IMETHODIMP nsEditor::DeleteSelectionAndCreateNode ( const nsAString &  aTag,
nsIDOMNode **  aNewNode 
)

Definition at line 4776 of file nsEditor.cpp.

{
  nsCOMPtr<nsIDOMNode> parentSelectedNode;
  PRInt32 offsetOfNewNode;
  nsresult result = DeleteSelectionAndPrepareToCreateNode(parentSelectedNode,
                                                          offsetOfNewNode);
  if (NS_FAILED(result))
    return result;

  nsCOMPtr<nsIDOMNode> newNode;
  result = CreateNode(aTag, parentSelectedNode, offsetOfNewNode,
                      getter_AddRefs(newNode));
  // XXX: ERROR_HANDLING  check result, and make sure aNewNode is set correctly in success/failure cases
  *aNewNode = newNode;
  NS_IF_ADDREF(*aNewNode);

  // we want the selection to be just after the new node
  nsCOMPtr<nsISelection> selection;
  result = GetSelection(getter_AddRefs(selection));
  if (NS_FAILED(result)) return result;
  if (!selection) return NS_ERROR_NULL_POINTER;
  return selection->Collapse(parentSelectedNode, offsetOfNewNode+1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode ( nsCOMPtr< nsIDOMNode > &  parentSelectedNode,
PRInt32 offsetOfNewNode 
) [protected]

Definition at line 4848 of file nsEditor.cpp.

{
  nsresult result=NS_ERROR_NOT_INITIALIZED;
  nsCOMPtr<nsISelection> selection;
  result = GetSelection(getter_AddRefs(selection));
  if (NS_FAILED(result)) return result;
  if (!selection) return NS_ERROR_NULL_POINTER;

  PRBool collapsed;
  result = selection->GetIsCollapsed(&collapsed);
  if (NS_SUCCEEDED(result) && !collapsed) 
  {
    result = DeleteSelection(nsIEditor::eNone);
    if (NS_FAILED(result)) {
      return result;
    }
    // get the new selection
    result = GetSelection(getter_AddRefs(selection));
    if (NS_FAILED(result)) {
      return result;
    }
#ifdef NS_DEBUG
    nsCOMPtr<nsIDOMNode>testSelectedNode;
    nsresult debugResult = selection->GetAnchorNode(getter_AddRefs(testSelectedNode));
    // no selection is ok.
    // if there is a selection, it must be collapsed
    if (testSelectedNode)
    {
      PRBool testCollapsed;
      debugResult = selection->GetIsCollapsed(&testCollapsed);
      NS_ASSERTION((NS_SUCCEEDED(result)), "couldn't get a selection after deletion");
      NS_ASSERTION(testCollapsed, "selection not reset after deletion");
    }
#endif
  }
  // split the selected node
  PRInt32 offsetOfSelectedNode;
  result = selection->GetAnchorNode(getter_AddRefs(parentSelectedNode));
  if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offsetOfSelectedNode)) && parentSelectedNode)
  {
    nsCOMPtr<nsIDOMNode> selectedNode;
    PRUint32 selectedNodeContentCount=0;
    nsCOMPtr<nsIDOMCharacterData>selectedParentNodeAsText;
    selectedParentNodeAsText = do_QueryInterface(parentSelectedNode);

    offsetOfNewNode = offsetOfSelectedNode;
    
    /* if the selection is a text node, split the text node if necesary
       and compute where to put the new node
    */
    if (selectedParentNodeAsText) 
    { 
      PRInt32 indexOfTextNodeInParent;
      selectedNode = do_QueryInterface(parentSelectedNode);
      selectedNode->GetParentNode(getter_AddRefs(parentSelectedNode));
      selectedParentNodeAsText->GetLength(&selectedNodeContentCount);
      GetChildOffset(selectedNode, parentSelectedNode, indexOfTextNodeInParent);

      if ((offsetOfSelectedNode!=0) && (((PRUint32)offsetOfSelectedNode)!=selectedNodeContentCount))
      {
        nsCOMPtr<nsIDOMNode> newSiblingNode;
        result = SplitNode(selectedNode, offsetOfSelectedNode, getter_AddRefs(newSiblingNode));
        // now get the node's offset in it's parent, and insert the new tag there
        if (NS_SUCCEEDED(result)) {
          result = GetChildOffset(selectedNode, parentSelectedNode, offsetOfNewNode);
        }
      }
      else 
      { // determine where to insert the new node
        if (0==offsetOfSelectedNode) {
          offsetOfNewNode = indexOfTextNodeInParent; // insert new node as previous sibling to selection parent
        }
        else {                 // insert new node as last child
          GetChildOffset(selectedNode, parentSelectedNode, offsetOfNewNode);
          offsetOfNewNode++;    // offsets are 0-based, and we need the index of the new node
        }
      }
    }
    // Here's where the new node was inserted
  }
#ifdef DEBUG
  else {
    printf("InsertLineBreak into an empty document is not yet supported\n");
  }
#endif
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4734 of file nsEditor.cpp.

{
  nsCOMPtr<nsISelection>selection;
  nsresult res = GetSelection(getter_AddRefs(selection));
  if (NS_FAILED(res)) return res;
  nsRefPtr<EditAggregateTxn> txn;
  res = CreateTxnForDeleteSelection(aAction, getter_AddRefs(txn));
  if (NS_FAILED(res)) return res;
  nsAutoRules beginRulesSniffing(this, kOpDeleteSelection, aAction);

  PRInt32 i;
  nsIEditActionListener *listener;
  if (NS_SUCCEEDED(res))  
  {
    if (mActionListeners)
    {
      for (i = 0; i < mActionListeners->Count(); i++)
      {
        listener = (nsIEditActionListener *)mActionListeners->ElementAt(i);
        if (listener)
          listener->WillDeleteSelection(selection);
      }
    }

    res = DoTransaction(txn);  

    if (mActionListeners)
    {
      for (i = 0; i < mActionListeners->Count(); i++)
      {
        listener = (nsIEditActionListener *)mActionListeners->ElementAt(i);
        if (listener)
          listener->DidDeleteSelection(selection);
      }
    }
  }

  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsEditor::DeleteText ( nsIDOMCharacterData aElement,
PRUint32  aOffset,
PRUint32  aLength 
) [protected]

Reimplemented in nsHTMLEditor.

Definition at line 3066 of file nsEditor.cpp.

{
  nsRefPtr<DeleteTextTxn> txn;
  nsresult result = CreateTxnForDeleteText(aElement, aOffset, aLength,
                                           getter_AddRefs(txn));
  nsAutoRules beginRulesSniffing(this, kOpDeleteText, nsIEditor::ePrevious);
  if (NS_SUCCEEDED(result))  
  {
    // let listeners know whats up
    PRInt32 i;
    nsIEditActionListener *listener;
    if (mActionListeners)
    {
      for (i = 0; i < mActionListeners->Count(); i++)
      {
        listener = (nsIEditActionListener *)mActionListeners->ElementAt(i);
        if (listener)
          listener->WillDeleteText(aElement, aOffset, aLength);
      }
    }
    
    result = DoTransaction(txn); 
    
    // let listeners know what happened
    if (mActionListeners)
    {
      for (i = 0; i < mActionListeners->Count(); i++)
      {
        listener = (nsIEditActionListener *)mActionListeners->ElementAt(i);
        if (listener)
          listener->DidDeleteText(aElement, aOffset, aLength, result);
      }
    }
  }
  return result;
}

Here is the call graph for this function:

Definition at line 4939 of file nsEditor.cpp.

{
  nsresult rv = NS_OK;
  
  PRBool  isTransientTransaction;
  rv = aTxn->GetIsTransient(&isTransientTransaction);
  if (NS_FAILED(rv))
    return rv;
  
  if (!isTransientTransaction)
  {
    // we need to deal here with the case where the user saved after some
    // edits, then undid one or more times. Then, the undo count is -ve,
    // but we can't let a do take it back to zero. So we flip it up to
    // a +ve number.
    PRInt32 modCount;
    GetModificationCount(&modCount);
    if (modCount < 0)
      modCount = -modCount;
        
    rv = IncrementModificationCount(1);    // don't count transient transactions
  }
  
  return rv;
}

Definition at line 4977 of file nsEditor.cpp.

{
  return IncrementModificationCount(1);    // all redoable transactions are non-transient
}

Definition at line 4967 of file nsEditor.cpp.

{
  nsresult rv = NS_OK;

  rv = IncrementModificationCount(-1);    // all undoable transactions are non-transient

  return rv;
}
void nsIEditor::doDrag ( in nsIDOMEvent  aEvent) [inherited]

doDrag transfers the relevant data (as appropriate) to a transferable so it can later be dropped.

doTransaction() fires a transaction.

It is provided here so clients can create their own transactions. If a transaction manager is present, it is used. Otherwise, the transaction is just executed directly.

Parameters:
aTxnthe transaction to execute

And a debug method -- show us what the tree looks like right now.

void nsIEditor::enableUndo ( in boolean  enable) [inherited]

turn the undo system on or off

Parameters:
aEnableif PR_TRUE, the undo system is turned on if available if PR_FALSE the undo system is turned off if it was previously on
Returns:
if aEnable is PR_TRUE, returns NS_OK if the undo system could be initialized properly if aEnable is PR_FALSE, returns NS_OK.

endComposition() Handles the end of inline input composition.

void nsIEditor::endOfDocument ( ) [inherited]

sets the document selection to the end of the document

All editor operations which alter the doc should be followed with a call to EndOperation.

Reimplemented in nsHTMLEditor, and nsPlaintextEditor.

Definition at line 2544 of file nsEditor.cpp.

{
  mAction = nsnull;
  mDirection = eNone;
  return NS_OK;
}

Here is the caller graph for this function:

endTransaction is a signal to the editor that the caller is finished updating the content model.


beginUpdate must be called before endTransaction is called.
Calls to beginTransaction can be nested, as long as endTransaction is called once per beginTransaction.

Reimplemented in nsHTMLEditor.

Definition at line 4641 of file nsEditor.cpp.

{
  NS_PRECONDITION(mUpdateCount > 0, "bad state");
  
  if (mUpdateCount <= 0)
  {
    mUpdateCount = 0;
    return NS_ERROR_FAILURE;
  }

  mUpdateCount--;

  if (0 == mUpdateCount)
  {
    // Hide the caret with an StCaretHider. By the time it goes out
    // of scope and tries to show the caret, reflow and selection changed
    // notifications should've happened so the caret should have enough info
    // to draw at the correct position.

    nsCOMPtr<nsICaret> caret;
    nsCOMPtr<nsIPresShell> presShell;
    GetPresShell(getter_AddRefs(presShell));

    if (presShell)
      presShell->GetCaret(getter_AddRefs(caret));

    StCaretHider caretHider(caret);
        
    PRUint32 flags = 0;

    GetFlags(&flags);

    // Turn reflow back on.
    //
    // Make sure we enable reflowing before we call
    // mViewManager->EndUpdateViewBatch().  This will make sure that any
    // new updates caused by a reflow, that may happen during the
    // EndReflowBatching(), get included if we force a refresh during
    // the mViewManager->EndUpdateViewBatch() call.

    if (presShell)
    {
      PRBool forceReflow = PR_TRUE;

      if (flags & nsIPlaintextEditor::eEditorUseAsyncUpdatesMask)
        forceReflow = PR_FALSE;

      presShell->EndReflowBatching(forceReflow);
    }

    // Turn view updating back on.

    if (mViewManager)
    {
      PRUint32 updateFlag = NS_VMREFRESH_IMMEDIATE;

      // If we're doing async updates, use NS_VMREFRESH_DEFERRED here, so that
      // the reflows we caused will get processed before the invalidates.
      if (flags & nsIPlaintextEditor::eEditorUseAsyncUpdatesMask)
        updateFlag = NS_VMREFRESH_DEFERRED;

      mViewManager->EndUpdateViewBatch(updateFlag);
    }

    // Turn selection updating and notifications back on.

    nsCOMPtr<nsISelection>selection;
    GetSelection(getter_AddRefs(selection));

    if (selection) {
      nsCOMPtr<nsISelectionPrivate>selPrivate(do_QueryInterface(selection));
      selPrivate->EndBatchChanges();
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

forceCompositionEnd() force the composition end

boolean nsIEditor::getAttributeValue ( in nsIDOMElement  aElement,
in AString  attributestr,
out AString  resultValue 
) [inherited]

getAttributeValue() retrieves the attribute's value for aElement.

Parameters:
aElementthe content element to operate on
aAttributethe string representation of the attribute to get
aResultValue[OUT] the value of aAttribute. Only valid if aResultIsSet is PR_TRUE
Returns:
PR_TRUE if aAttribute is set on the current node, PR_FALSE if it is not.
nsCOMPtr< nsIDOMNode > nsEditor::GetChildAt ( nsIDOMNode aParent,
PRInt32  aOffset 
) [static]

Definition at line 4318 of file nsEditor.cpp.

{
  nsCOMPtr<nsIDOMNode> resultNode;
  
  nsCOMPtr<nsIContent> parent = do_QueryInterface(aParent);

  if (!parent) 
    return resultNode;

  resultNode = do_QueryInterface(parent->GetChildAt(aOffset));

  return resultNode;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEditor::GetChildOffset ( nsIDOMNode aChild,
nsIDOMNode aParent,
PRInt32 aOffset 
) [static]

Set aOffset to the offset of aChild in aParent.

Returns an error if aChild is not an immediate child of aParent.

Definition at line 3501 of file nsEditor.cpp.

{
  NS_ASSERTION((aChild && aParent), "bad args");

  nsCOMPtr<nsIContent> content = do_QueryInterface(aParent);
  nsCOMPtr<nsIContent> cChild = do_QueryInterface(aChild);
  if (!cChild || !content)
    return NS_ERROR_NULL_POINTER;

  aOffset = content->IndexOf(cChild);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Return true if spellchecking should be enabled for this editor.

Definition at line 489 of file nsEditor.cpp.

{
  // Check user override on this element
  if (mSpellcheckCheckboxState != eTriUnset) {
    return (mSpellcheckCheckboxState == eTriTrue);
  }

  // Check user preferences
  nsresult rv;
  nsCOMPtr<nsIPrefBranch> prefBranch =
    do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
  PRInt32 spellcheckLevel = 1;
  if (NS_SUCCEEDED(rv) && prefBranch) {
    prefBranch->GetIntPref("layout.spellcheckDefault", &spellcheckLevel);
  }

  if (spellcheckLevel == 0) {
    return PR_FALSE;                    // Spellchecking forced off globally
  }

  // Check for password/readonly/disabled, which are not spellchecked
  // regardless of DOM
  PRUint32 flags;
  if (NS_SUCCEEDED(GetFlags(&flags)) &&
      flags & (nsIPlaintextEditor::eEditorPasswordMask |
               nsIPlaintextEditor::eEditorReadonlyMask |
               nsIPlaintextEditor::eEditorDisabledMask)) {
    return PR_FALSE;
  }

  nsCOMPtr<nsIPresShell> presShell;
  rv = GetPresShell(getter_AddRefs(presShell));
  if (NS_SUCCEEDED(rv)) {
    nsPresContext* context = presShell->GetPresContext();
    if (context->Type() == nsPresContext::eContext_PrintPreview ||
        context->Type() == nsPresContext::eContext_Print) {
      return PR_FALSE;
    }
  }

  // Check DOM state
  nsCOMPtr<nsIContent> content = do_QueryInterface(GetRoot());
  if (!content) {
    return PR_FALSE;
  }

  if (content->IsNativeAnonymous()) {
    content = content->GetParent();
  }

  nsCOMPtr<nsIDOMNSHTMLElement_MOZILLA_1_8_BRANCH> element =
    do_QueryInterface(content);
  if (!element) {
    return PR_FALSE;
  }

  PRBool enable;
  element->GetSpellcheck(&enable);

  return enable;
}

Here is the call graph for this function:

Definition at line 5540 of file nsEditor.cpp.

{
  nsIDOMEventReceiver *erp = mDOMEventReceiver;
  if (erp)
  {
    NS_ADDREF(erp);
    return erp;
  }

  nsIDOMElement *rootElement = GetRoot();

  // Now hack to make sure we are not anonymous content.
  // If we are grab the parent of root element for our observer.

  nsCOMPtr<nsIContent> content = do_QueryInterface(rootElement);

  if (content && content->IsNativeAnonymous())
  {
    mDOMEventReceiver = do_QueryInterface(content->GetParent());
    erp = mDOMEventReceiver;
    NS_IF_ADDREF(erp);
  }
  else
  {
    // Don't use getDocument here, because we have no way of knowing
    // if Init() was ever called.  So we need to get the document
    // ourselves, if it exists.
    if (mDocWeak)
    {
      CallQueryReferent(mDocWeak.get(), &erp);
    }
    else
    {
      NS_ERROR("not initialized yet");
    }
  }

  return erp;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEditor::GetEndNodeAndOffset ( nsISelection aSelection,
nsCOMPtr< nsIDOMNode > *  outEndNode,
PRInt32 outEndOffset 
) [static]

Definition at line 4376 of file nsEditor.cpp.

{
  if (!outEndNode || !outEndOffset) 
    return NS_ERROR_NULL_POINTER;
    
  nsCOMPtr<nsISelectionPrivate>selPrivate(do_QueryInterface(aSelection));
  nsCOMPtr<nsIEnumerator> enumerator;
  nsresult result = selPrivate->GetEnumerator(getter_AddRefs(enumerator));
  if (NS_FAILED(result) || !enumerator)
    return NS_ERROR_FAILURE;
    
  enumerator->First(); 
  nsCOMPtr<nsISupports> currentItem;
  if (NS_FAILED(enumerator->CurrentItem(getter_AddRefs(currentItem))))
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIDOMRange> range( do_QueryInterface(currentItem) );
  if (!range)
    return NS_ERROR_FAILURE;
    
  if (NS_FAILED(range->GetEndContainer(getter_AddRefs(*outEndNode))))
    return NS_ERROR_FAILURE;
    
  if (NS_FAILED(range->GetEndOffset(outEndOffset)))
    return NS_ERROR_FAILURE;
    
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Find the deep first and last children.

Returned nodes are AddReffed

Definition at line 2932 of file nsEditor.cpp.

{
  if (!aRoot || !outFirstNode) return NS_ERROR_NULL_POINTER;
  nsresult rv = NS_OK;
  *outFirstNode = nsnull;

  nsCOMPtr<nsIDOMNode> node = GetLeftmostChild(aRoot);
  if (node && !IsEditable(node))
  {
    nsCOMPtr<nsIDOMNode> next;
    rv = GetNextNode(node, PR_TRUE, address_of(next));
    node = next;
  }
  
  if (node != aRoot)
    *outFirstNode = node;

  return rv;
}

Here is the call graph for this function:

Definition at line 4805 of file nsEditor.cpp.

{
  *length = mIMEBufferLength;
  return NS_OK;
}

Here is the caller graph for this function:

PRInt32 nsEditor::GetIndexOf ( nsIDOMNode aParent,
nsIDOMNode aChild 
) [static]

Definition at line 4303 of file nsEditor.cpp.

{
  nsCOMPtr<nsIContent> content = do_QueryInterface(parent);
  nsCOMPtr<nsIContent> cChild = do_QueryInterface(child);
  NS_PRECONDITION(content, "null content in nsEditor::GetIndexOf");
  NS_PRECONDITION(cChild, "null content in nsEditor::GetIndexOf");

  return content->IndexOf(cChild);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the inline spell checker associated with this object.

The spell checker is lazily created, so this function may create the object for you during this call.

Parameters:
autoCreateIf true, this will create a spell checker object if one does not exist yet for this editor. If false and the object has not been created, this function WILL RETURN NULL.

Definition at line 2325 of file nsEditor.cpp.

{
  if (!aKBSC)
    return NS_ERROR_NULL_POINTER;
  *aKBSC = nsnull;
  nsCOMPtr<nsIPresShell> shell;
  nsresult res = GetPresShell(getter_AddRefs(shell));

  if (NS_FAILED(res))
    return res;

  if (!shell)
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIWidget> widget;
  res = GetEditorContentWindow(shell, GetRoot(), getter_AddRefs(widget));
  if (NS_FAILED(res))
    return res;

  nsCOMPtr<nsIKBStateControl> kb = do_QueryInterface(widget);
  if (!kb)
    return NS_ERROR_NOT_INITIALIZED;

  NS_ADDREF(*aKBSC = kb);

  return NS_OK;
}

Here is the call graph for this function:

nsCOMPtr< nsIDOMNode > nsEditor::GetLeftmostChild ( nsIDOMNode aCurrentNode,
PRBool  bNoBlockCrossing = PR_FALSE 
)

Get the leftmost child of aCurrentNode; return nsnull if aCurrentNode has no children.

Definition at line 3912 of file nsEditor.cpp.

{
  if (!aCurrentNode) return nsnull;
  nsCOMPtr<nsIDOMNode> resultNode, temp=aCurrentNode;
  PRBool hasChildren;
  aCurrentNode->HasChildNodes(&hasChildren);
  while (hasChildren)
  {
    temp->GetFirstChild(getter_AddRefs(resultNode));
    if (resultNode)
    {
      if (bNoBlockCrossing && IsBlockNode(resultNode))
         return resultNode;
      resultNode->HasChildNodes(&hasChildren);
      temp = resultNode;
    }
    else 
      hasChildren = PR_FALSE;
  }

  return resultNode;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEditor::GetLengthOfDOMNode ( nsIDOMNode aNode,
PRUint32 aCount 
) [static]

returns the number of things inside aNode in the out-param aCount.

Parameters:
aNodeis the node to get the length of. If aNode is text, returns number of characters. If not, returns number of children nodes.
aCount[OUT] the result of the above calculation.

Definition at line 3534 of file nsEditor.cpp.

{
  aCount = 0;
  if (!aNode) { return NS_ERROR_NULL_POINTER; }
  nsresult result=NS_OK;
  nsCOMPtr<nsIDOMCharacterData>nodeAsChar = do_QueryInterface(aNode);
  if (nodeAsChar) {
    nodeAsChar->GetLength(&aCount);
  }
  else
  {
    PRBool hasChildNodes;
    aNode->HasChildNodes(&hasChildNodes);
    if (hasChildNodes)
    {
      nsCOMPtr<nsIDOMNodeList>nodeList;
      result = aNode->GetChildNodes(getter_AddRefs(nodeList));
      if (NS_SUCCEEDED(result) && nodeList) {
        nodeList->GetLength(&aCount);
      }
    }
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Gets the modification count of the document we are editing.

Returns:
the modification count of the document being edited. Zero means unchanged.
nsresult nsEditor::GetNextNode ( nsIDOMNode aCurrentNode,
PRBool  aEditableNode,
nsCOMPtr< nsIDOMNode > *  aResultNode,
PRBool  bNoBlockCrossing = PR_FALSE 
)

get the node immediately after to aCurrentNode

Parameters:
aCurrentNodethe node from which we start the search
aEditableNodeif PR_TRUE, only return an editable node
aResultNode[OUT] the node that occurs after aCurrentNode in the tree, skipping non-editable nodes if aEditableNode is PR_TRUE. If there is no prior node, aResultNode will be nsnull.

Definition at line 3773 of file nsEditor.cpp.

{
  if (!aCurrentNode || !aResultNode) { return NS_ERROR_NULL_POINTER; }
  
  *aResultNode = nsnull;  // init out-param

  if (IsRootNode(aCurrentNode))
  {
    // Don't allow traversal above the root node! This helps
    // prevent us from accidentally editing browser content
    // when the editor is in a text widget.

    return NS_OK;
  }

  nsCOMPtr<nsIDOMNode> candidate;
  nsresult result = GetNextNodeImpl(aCurrentNode, aEditableNode,
                                    address_of(candidate), bNoBlockCrossing);
  if (NS_FAILED(result)) return result;
  
  if (!candidate)
  {
    // we could not find a next node.  return null.
    *aResultNode = nsnull;
    return NS_OK;
  }
  else if (!aEditableNode) *aResultNode = candidate;
  else if (IsEditable(candidate)) *aResultNode = candidate;
  else 
  { // restart the search from the non-editable node we just found
    nsCOMPtr<nsIDOMNode> notEditableNode = do_QueryInterface(candidate);
    return GetNextNode(notEditableNode, aEditableNode, aResultNode, bNoBlockCrossing);
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEditor::GetNextNode ( nsIDOMNode aParentNode,
PRInt32  aOffset,
PRBool  aEditableNode,
nsCOMPtr< nsIDOMNode > *  aResultNode,
PRBool  bNoBlockCrossing = PR_FALSE 
)

Definition at line 3601 of file nsEditor.cpp.

{
  // just another version of GetNextNode that takes a {parent, offset}
  // instead of a node
  if (!aParentNode || !aResultNode) { return NS_ERROR_NULL_POINTER; }
  
  *aResultNode = nsnull;

  // if aParentNode is a text node, use it's location instead
  if (IsTextNode(aParentNode))
  {
    nsCOMPtr<nsIDOMNode> parent;
    nsEditor::GetNodeLocation(aParentNode, address_of(parent), &aOffset);
    aParentNode = parent;
    aOffset++;  // _after_ the text node
  }
  // look at the child at 'aOffset'
  nsCOMPtr<nsIDOMNode> child = GetChildAt(aParentNode, aOffset);
  if (child)
  {
    if (bNoBlockCrossing && IsBlockNode(child))
    {
      *aResultNode = child;  // return this block
      return NS_OK;
    }
    *aResultNode = GetLeftmostChild(child, bNoBlockCrossing);
    if (!*aResultNode) 
    {
      *aResultNode = child;
      return NS_OK;
    }
    if (!IsDescendantOfBody(*aResultNode))
    {
      *aResultNode = nsnull;
      return NS_OK;
    }

    if (!aEditableNode || IsEditable(*aResultNode))
      return NS_OK;

    // restart the search from the non-editable node we just found
    nsCOMPtr<nsIDOMNode> notEditableNode = do_QueryInterface(*aResultNode);
    return GetNextNode(notEditableNode, aEditableNode, aResultNode, bNoBlockCrossing);
  }
    
  // unless there isn't one, in which case we are at the end of the node
  // and want the next one.
  if (bNoBlockCrossing && IsBlockNode(aParentNode))
  {
    // don't cross out of parent block
    return NS_OK;
  }
  return GetNextNode(aParentNode, aEditableNode, aResultNode, bNoBlockCrossing);
}

Here is the call graph for this function:

nsresult nsEditor::GetNextNodeImpl ( nsIDOMNode aCurrentNode,
PRBool  aEditableNode,
nsCOMPtr< nsIDOMNode > *  aResultNode,
PRBool  bNoBlockCrossing = PR_FALSE 
) [protected]

Definition at line 3814 of file nsEditor.cpp.

{
  // called only by GetNextNode so we don't need to check params.

  // if aCurrentNode has a right sibling, return that sibling's leftmost child (or itself if it has no children)
  nsCOMPtr<nsIDOMNode> nextSibling;
  nsresult result = aCurrentNode->GetNextSibling(getter_AddRefs(nextSibling));
  if ((NS_SUCCEEDED(result)) && nextSibling)
  {
    if (bNoBlockCrossing && IsBlockNode(nextSibling))
    {
      // next sibling is a block, do not step into it
      *aResultNode = nextSibling;
      return NS_OK;
    }
    *aResultNode = GetLeftmostChild(nextSibling, bNoBlockCrossing);
    if (!*aResultNode)
    { 
      *aResultNode = nextSibling;
      return NS_OK; 
    }
    if (!IsDescendantOfBody(*aResultNode))
    {
      *aResultNode = nsnull;
      return NS_OK;
    }
  }
  else
  {
    // otherwise, walk up the parent tree until there is a child that comes after 
    // the ancestor of aCurrentNode.  Then return that node's leftmost child
    nsCOMPtr<nsIDOMNode> parent(do_QueryInterface(aCurrentNode));
    nsCOMPtr<nsIDOMNode> node, notEditableNode;
    do {
      node = parent;
      result = node->GetParentNode(getter_AddRefs(parent));
      if ((NS_SUCCEEDED(result)) && parent)
      {
        if (!IsDescendantOfBody(parent))
        {
          *aResultNode = nsnull;
          return NS_OK;
        }
        if ((bNoBlockCrossing && IsBlockNode(parent)) || IsRootNode(parent))
        {
          // we are at end of block or root, do not step out
          *aResultNode = nsnull;
          return NS_OK;
        }
        result = parent->GetNextSibling(getter_AddRefs(node));
        if ((NS_SUCCEEDED(result)) && node)
        {
          if (bNoBlockCrossing && IsBlockNode(node))
          {
            // next sibling is a block, do not step into it
            *aResultNode = node;
            return NS_OK;
          }
          *aResultNode = GetLeftmostChild(node, bNoBlockCrossing);
          if (!*aResultNode) *aResultNode = node;
          return NS_OK; 
        }
      }
    } while ((NS_SUCCEEDED(result)) && parent);
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEditor::GetNodeLocation ( nsIDOMNode aChild,
nsCOMPtr< nsIDOMNode > *  aParent,
PRInt32 aOffset 
) [static]

Set aParent to the parent of aChild.

Set aOffset to the offset of aChild in aParent.

Definition at line 3516 of file nsEditor.cpp.

{
  NS_ASSERTION((inChild && outParent && outOffset), "bad args");
  nsresult result = NS_ERROR_NULL_POINTER;
  if (inChild && outParent && outOffset)
  {
    result = inChild->GetParentNode(getter_AddRefs(*outParent));
    if ((NS_SUCCEEDED(result)) && (*outParent))
    {
      result = GetChildOffset(inChild, *outParent, *outOffset);
    }
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 619 of file nsEditor.cpp.

{
  if (!aPS)
    return NS_ERROR_NULL_POINTER;
  *aPS = nsnull; // init out param
  NS_PRECONDITION(mPresShellWeak, "bad state, null mPresShellWeak");
  nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
  if (!ps) return NS_ERROR_NOT_INITIALIZED;
  NS_ADDREF(*aPS = ps);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEditor::GetPriorNode ( nsIDOMNode aCurrentNode,
PRBool  aEditableNode,
nsCOMPtr< nsIDOMNode > *  aResultNode,
PRBool  bNoBlockCrossing = PR_FALSE 
)

get the node immediately prior to aCurrentNode

Parameters:
aCurrentNodethe node from which we start the search
aEditableNodeif PR_TRUE, only return an editable node
aResultNode[OUT] the node that occurs before aCurrentNode in the tree, skipping non-editable nodes if aEditableNode is PR_TRUE. If there is no prior node, aResultNode will be nsnull.

Definition at line 3662 of file nsEditor.cpp.

{
  nsresult result;
  if (!aCurrentNode || !aResultNode) { return NS_ERROR_NULL_POINTER; }
  
  *aResultNode = nsnull;  // init out-param

  if (IsRootNode(aCurrentNode))
  {
    // Don't allow traversal above the root node! This helps
    // prevent us from accidentally editing browser content
    // when the editor is in a text widget.

    return NS_OK;
  }

  nsCOMPtr<nsIDOMNode> candidate;
  result = GetPriorNodeImpl(aCurrentNode, aEditableNode, address_of(candidate), bNoBlockCrossing);
  if (NS_FAILED(result)) return result;
  
  if (!candidate)
  {
    // we could not find a prior node.  return null.
    return NS_OK;
  }
  else if (!aEditableNode) *aResultNode = candidate;
  else if (IsEditable(candidate)) *aResultNode = candidate;
  else 
  { // restart the search from the non-editable node we just found
    nsCOMPtr<nsIDOMNode> notEditableNode = do_QueryInterface(candidate);
    return GetPriorNode(notEditableNode, aEditableNode, aResultNode, bNoBlockCrossing);
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEditor::GetPriorNode ( nsIDOMNode aParentNode,
PRInt32  aOffset,
PRBool  aEditableNode,
nsCOMPtr< nsIDOMNode > *  aResultNode,
PRBool  bNoBlockCrossing = PR_FALSE 
)

Definition at line 3561 of file nsEditor.cpp.

{
  // just another version of GetPriorNode that takes a {parent, offset}
  // instead of a node
  if (!aParentNode || !aResultNode) { return NS_ERROR_NULL_POINTER; }
  *aResultNode = nsnull;
  
  // if we are at beginning of node, or it is a textnode, then just look before it
  if (!aOffset || IsTextNode(aParentNode))
  {
    if (bNoBlockCrossing && IsBlockNode(aParentNode))
    {
      // if we aren't allowed to cross blocks, don't look before this block
      return NS_OK;
    }
    return GetPriorNode(aParentNode, aEditableNode, aResultNode, bNoBlockCrossing);
  }

  // else look before the child at 'aOffset'
  nsCOMPtr<nsIDOMNode> child = GetChildAt(aParentNode, aOffset);
  if (child)
    return GetPriorNode(child, aEditableNode, aResultNode, bNoBlockCrossing);

  // unless there isn't one, in which case we are at the end of the node
  // and want the deep-right child.
  *aResultNode = GetRightmostChild(aParentNode, bNoBlockCrossing);
  if (!*aResultNode || !aEditableNode || IsEditable(*aResultNode))
    return NS_OK;

  // restart the search from the non-editable node we just found
  nsCOMPtr<nsIDOMNode> notEditableNode = do_QueryInterface(*aResultNode);
  return GetPriorNode(notEditableNode, aEditableNode, aResultNode, bNoBlockCrossing);
}

Here is the call graph for this function:

nsresult nsEditor::GetPriorNodeImpl ( nsIDOMNode aCurrentNode,
PRBool  aEditableNode,
nsCOMPtr< nsIDOMNode > *  aResultNode,
PRBool  bNoBlockCrossing = PR_FALSE 
) [protected]

Definition at line 3701 of file nsEditor.cpp.

{
  // called only by GetPriorNode so we don't need to check params.

  // if aCurrentNode has a left sibling, return that sibling's rightmost child (or itself if it has no children)
  nsCOMPtr<nsIDOMNode> prevSibling;
  nsresult result = aCurrentNode->GetPreviousSibling(getter_AddRefs(prevSibling));
  if ((NS_SUCCEEDED(result)) && prevSibling)
  {
    if (bNoBlockCrossing && IsBlockNode(prevSibling))
    {
      // don't look inside prevsib, since it is a block
      *aResultNode = prevSibling;
      return NS_OK;
    }
    *aResultNode = GetRightmostChild(prevSibling, bNoBlockCrossing);
    if (!*aResultNode) 
    { 
      *aResultNode = prevSibling;
      return NS_OK;
    }
    if (!IsDescendantOfBody(*aResultNode))
    {
      *aResultNode = nsnull;
      return NS_OK;
    }
  }
  else
  {
    // otherwise, walk up the parent tree until there is a child that comes before 
    // the ancestor of aCurrentNode.  Then return that node's rightmost child
    nsCOMPtr<nsIDOMNode> parent = do_QueryInterface(aCurrentNode);
    nsCOMPtr<nsIDOMNode> node, notEditableNode;
    do {
      node = parent;
      result = node->GetParentNode(getter_AddRefs(parent));
      if ((NS_SUCCEEDED(result)) && parent)
      {
        if (!IsDescendantOfBody(parent))
        {
          *aResultNode = nsnull;
          return NS_OK;
        }
        if ((bNoBlockCrossing && IsBlockNode(parent)) || IsRootNode(parent))
        {
          // we are at front of block or root, do not step out
          *aResultNode = nsnull;
          return NS_OK;
        }
        result = parent->GetPreviousSibling(getter_AddRefs(node));
        if ((NS_SUCCEEDED(result)) && node)
        {
          if (bNoBlockCrossing && IsBlockNode(node))
          {
            // prev sibling is a block, do not step into it
            *aResultNode = node;
            return NS_OK;
          }
          *aResultNode = GetRightmostChild(node, bNoBlockCrossing);
          if (!*aResultNode)  *aResultNode = node;
          return NS_OK;
        }
      }
    } while ((NS_SUCCEEDED(result)) && parent && !*aResultNode);
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

getQueryCaretRect() Get the query caret rect

getReconversionString() Get the reconvertion string

nsCOMPtr< nsIDOMNode > nsEditor::GetRightmostChild ( nsIDOMNode aCurrentNode,
PRBool  bNoBlockCrossing = PR_FALSE 
)

Get the rightmost child of aCurrentNode; return nsnull if aCurrentNode has no children.

Definition at line 3887 of file nsEditor.cpp.

{
  if (!aCurrentNode) return nsnull;
  nsCOMPtr<nsIDOMNode> resultNode, temp=aCurrentNode;
  PRBool hasChildren;
  aCurrentNode->HasChildNodes(&hasChildren);
  while (hasChildren)
  {
    temp->GetLastChild(getter_AddRefs(resultNode));
    if (resultNode)
    {
      if (bNoBlockCrossing && IsBlockNode(resultNode))
         return resultNode;
      resultNode->HasChildNodes(&hasChildren);
      temp = resultNode;
    }
    else 
      hasChildren = PR_FALSE;
  }

  return resultNode;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 5581 of file nsEditor.cpp.

{
  if (!mRootElement)
  {
    nsCOMPtr<nsIDOMElement> root;

    // Let GetRootElement() do the work
    GetRootElement(getter_AddRefs(root));
  }

  return mRootElement;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4720 of file nsEditor.cpp.

Here is the caller graph for this function:

nsresult nsEditor::GetStartNodeAndOffset ( nsISelection aSelection,
nsCOMPtr< nsIDOMNode > *  outStartNode,
PRInt32 outStartOffset 
) [static]

Definition at line 4338 of file nsEditor.cpp.

{
  if (!outStartNode || !outStartOffset || !aSelection) 
    return NS_ERROR_NULL_POINTER;

  // brade:  set outStartNode to null or ?

  nsCOMPtr<nsISelectionPrivate>selPrivate(do_QueryInterface(aSelection));
  nsCOMPtr<nsIEnumerator> enumerator;
  nsresult result = selPrivate->GetEnumerator(getter_AddRefs(enumerator));
  if (NS_FAILED(result) || !enumerator)
    return NS_ERROR_FAILURE;
    
  enumerator->First(); 
  nsCOMPtr<nsISupports> currentItem;
  if (NS_FAILED(enumerator->CurrentItem(getter_AddRefs(currentItem))))
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIDOMRange> range( do_QueryInterface(currentItem) );
  if (!range)
    return NS_ERROR_FAILURE;
    
  if (NS_FAILED(range->GetStartContainer(getter_AddRefs(*outStartNode))))
    return NS_ERROR_FAILURE;
    
  if (NS_FAILED(range->GetStartOffset(outStartOffset)))
    return NS_ERROR_FAILURE;
    
  return NS_OK;
}

Here is the call graph for this function:

nsresult nsEditor::GetString ( const nsAString &  name,
nsAString &  value 
)
nsIAtom * nsEditor::GetTag ( nsIDOMNode aNode) [static]

Definition at line 4209 of file nsEditor.cpp.

{
  nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);

  if (!content) 
  {
    NS_ASSERTION(aNode, "null node passed to nsEditor::Tag()");

    return nsnull;
  }
  
  return content->Tag();
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEditor::GetTagString ( nsIDOMNode aNode,
nsAString &  outString 
) [static]

from html rules code - migration in progress

Definition at line 4228 of file nsEditor.cpp.

{
  if (!aNode) 
  {
    NS_NOTREACHED("null node passed to nsEditor::GetTag()");
    return NS_ERROR_NULL_POINTER;
  }
  
  nsIAtom *atom = GetTag(aNode);
  if (!atom)
  {
    return NS_ERROR_FAILURE;
  }

  atom->ToString(outString);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEditor::GetTextNodeTag ( nsAString &  aOutString) [static]

return the string that represents text nodes in the content tree

static helper method

Definition at line 2724 of file nsEditor.cpp.

{
  aOutString.Truncate();
  static nsString *gTextNodeTag=nsnull;
  if (!gTextNodeTag)
  {
    if ( (gTextNodeTag = new nsString) == 0 )
      return NS_ERROR_OUT_OF_MEMORY;
    gTextNodeTag->AssignLiteral("special text node tag");
  }
  aOutString = *gTextNodeTag;
  return NS_OK;
}

Here is the caller graph for this function:

NS_IMETHODIMP nsEditor::GetWrapWidth ( PRInt32 aWrapCol) [protected]

Definition at line 1237 of file nsEditor.cpp.

{
  NS_ENSURE_ARG_POINTER(aWrapColumn);
  *aWrapColumn = 72;

  nsresult rv;
  nsCOMPtr<nsIPrefBranch> prefBranch =
    do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
  if (NS_SUCCEEDED(rv) && prefBranch)
    (void) prefBranch->GetIntPref("editor.htmlWrapColumn", aWrapColumn);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEditor::HandleInlineSpellCheck ( PRInt32  action,
nsISelection aSelection,
nsIDOMNode previousSelectedNode,
PRInt32  previousSelectedOffset,
nsIDOMNode aStartNode,
PRInt32  aStartOffset,
nsIDOMNode aEndNode,
PRInt32  aEndOffset 
)

Definition at line 5520 of file nsEditor.cpp.

{
  return mInlineSpellChecker ? mInlineSpellChecker->SpellCheckAfterEditorChange(action,
                                                       aSelection,
                                                       previousSelectedNode,
                                                       previousSelectedOffset,
                                                       aStartNode,
                                                       aStartOffset,
                                                       aEndNode,
                                                       aEndOffset) : NS_OK;
}

Here is the caller graph for this function:

void nsIEditor::incrementModificationCount ( in long  aModCount) [inherited]

called each time we modify the document.

Increments the modification count of the document.

Parameters:
aModCountthe number of modifications by which to increase or decrease the count
void nsIEditor::init ( in nsIDOMDocument  doc,
in nsIPresShellPtr  shell,
in nsIContentPtr  aRoot,
in nsISelectionController  aSelCon,
in unsigned long  aFlags 
) [inherited]

Init is to tell the implementation of nsIEditor to begin its services.

Parameters:
aDocThe dom document interface being observed
aPresShellTEMP: The presentation shell displaying the document. Once events can tell us from what pres shell they originated, this will no longer be necessary, and the editor will no longer be linked to a single pres shell.
aRootThis is the root of the editable section of this document. If it is null then we get root from document body.
aSelConthis should be used to get the selection location
aFlagsA bitmask of flags for specifying the behavior of the editor.
nsresult nsEditor::InsertContainerAbove ( nsIDOMNode inNode,
nsCOMPtr< nsIDOMNode > *  outNode,
const nsAString &  aNodeType,
const nsAString *  aAttribute = nsnull,
const nsAString *  aValue = nsnull 
)

Definition at line 1794 of file nsEditor.cpp.

{
  if (!inNode || !outNode)
    return NS_ERROR_NULL_POINTER;
  nsCOMPtr<nsIDOMNode> parent;
  PRInt32 offset;
  nsresult res = GetNodeLocation(inNode, address_of(parent), &offset);
  if (NS_FAILED(res)) return res;

  // create new container
  nsCOMPtr<nsIContent> newContent;

  //new call to use instead to get proper HTML element, bug# 39919
  res = CreateHTMLContent(aNodeType, getter_AddRefs(newContent));
  nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(newContent);
  if (NS_FAILED(res)) return res;
  *outNode = do_QueryInterface(elem);
  
  // set attribute if needed
  if (aAttribute && aValue && !aAttribute->IsEmpty())
  {
    res = elem->SetAttribute(*aAttribute, *aValue);
    if (NS_FAILED(res)) return res;
  }
  
  // notify our internal selection state listener
  nsAutoInsertContainerSelNotify selNotify(mRangeUpdater);
  
  // put inNode in new parent, outNode
  res = DeleteNode(inNode);
  if (NS_FAILED(res)) return res;
  res = InsertNode(inNode, *outNode, 0);
  if (NS_FAILED(res)) return res;
  
  // put new parent in doc
  return InsertNode(*outNode, parent, offset);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIEditor::insertFromDrop ( in nsIDOMEvent  aEvent) [inherited]

insertFromDrop looks for a dragsession and inserts the relevant data in response to a drop.

void nsIEditor::insertNode ( in nsIDOMNode  node,
in nsIDOMNode  parent,
in long  aPosition 
) [inherited]

insertNode inserts aNode into aParent at aPosition.

No checking is done to verify the legality of the insertion. That is the responsibility of the caller.

Parameters:
aNodeThe DOM Node to insert.
aParentThe node to insert the new object into
aPositionThe place in aParent to insert the new node 0=first child, 1=second child, etc. any number > number of current children = last child
NS_IMETHODIMP nsEditor::InsertTextImpl ( const nsAString &  aStringToInsert,
nsCOMPtr< nsIDOMNode > *  aInOutNode,
PRInt32 aInOutOffset,
nsIDOMDocument aDoc 
)

Definition at line 2739 of file nsEditor.cpp.

{
  // NOTE: caller *must* have already used nsAutoTxnsConserveSelection stack-based
  // class to turn off txn selection updating.  Caller also turned on rules sniffing
  // if desired.
  
  if (!aInOutNode || !*aInOutNode || !aInOutOffset || !aDoc) return NS_ERROR_NULL_POINTER;
  if (!mInIMEMode && aStringToInsert.IsEmpty()) return NS_OK;
  nsCOMPtr<nsIDOMText> nodeAsText = do_QueryInterface(*aInOutNode);
  PRInt32 offset = *aInOutOffset;
  nsresult res;
  if (mInIMEMode)
  {
    if (!nodeAsText)
    {
      // create a text node
      res = aDoc->CreateTextNode(EmptyString(), getter_AddRefs(nodeAsText));
      if (NS_FAILED(res)) return res;
      if (!nodeAsText) return NS_ERROR_NULL_POINTER;
      nsCOMPtr<nsIDOMNode> newNode = do_QueryInterface(nodeAsText);
      // then we insert it into the dom tree
      res = InsertNode(newNode, *aInOutNode, offset);
      if (NS_FAILED(res)) return res;
      offset = 0;
    }
    res = InsertTextIntoTextNodeImpl(aStringToInsert, nodeAsText, offset);
    if (NS_FAILED(res)) return res;
  }
  else
  {
    if (nodeAsText)
    {
      // we are inserting text into an existing text node.
      res = InsertTextIntoTextNodeImpl(aStringToInsert, nodeAsText, offset);
      if (NS_FAILED(res)) return res;
      *aInOutOffset += aStringToInsert.Length();
    }
    else
    {
      // we are inserting text into a non-text node
      // first we have to create a textnode (this also populates it with the text)
      res = aDoc->CreateTextNode(aStringToInsert, getter_AddRefs(nodeAsText));
      if (NS_FAILED(res)) return res;
      if (!nodeAsText) return NS_ERROR_NULL_POINTER;
      nsCOMPtr<nsIDOMNode> newNode = do_QueryInterface(nodeAsText);
      // then we insert it into the dom tree
      res = InsertNode(newNode, *aInOutNode, offset);
      if (NS_FAILED(res)) return res;
      *aInOutNode = newNode;
      *aInOutOffset = aStringToInsert.Length();
    }
  }
  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsEditor::InsertTextIntoTextNodeImpl ( const nsAString &  aStringToInsert,
nsIDOMCharacterData aTextNode,
PRInt32  aOffset,
PRBool  suppressIME = PR_FALSE 
)

Definition at line 2798 of file nsEditor.cpp.

{
  nsRefPtr<EditTxn> txn;
  nsresult result;
  // suppressIME s used when editor must insert text, yet this text is not
  // part of current ime operation.  example: adjusting whitespace around an ime insertion.
  if (mIMETextRangeList && mInIMEMode && !suppressIME)
  {
    if (!mIMETextNode)
    {
      mIMETextNode = aTextNode;
      mIMETextOffset = aOffset;
    }
    PRUint16 len ;
    result = mIMETextRangeList->GetLength(&len);
    if (NS_SUCCEEDED(result) && len > 0)
    {
      nsCOMPtr<nsIPrivateTextRange> range;
      for (PRUint16 i = 0; i < len; i++) 
      {
        result = mIMETextRangeList->Item(i, getter_AddRefs(range));
        if (NS_SUCCEEDED(result) && range)
        {
          PRUint16 type;
          result = range->GetRangeType(&type);
          if (NS_SUCCEEDED(result)) 
          {
            if (type == nsIPrivateTextRange::TEXTRANGE_RAWINPUT) 
            {
              PRUint16 start, end;
              result = range->GetRangeStart(&start);
              if (NS_SUCCEEDED(result)) 
              {
                result = range->GetRangeEnd(&end);
                if (NS_SUCCEEDED(result)) 
                {
                  if (!mPhonetic)
                    mPhonetic = new nsString();
                  if (mPhonetic)
                  {
                    nsAutoString tmp(aStringToInsert);                  
                    tmp.Mid(*mPhonetic, start, end-start);
                  }
                }
              }
            } // if
          }
        } // if
      } // for
    } // if

    nsRefPtr<IMETextTxn> imeTxn;
    result = CreateTxnForIMEText(aStringToInsert, getter_AddRefs(imeTxn));
    txn = imeTxn;
  }
  else
  {
    nsRefPtr<InsertTextTxn> insertTxn;
    result = CreateTxnForInsertText(aStringToInsert, aTextNode, aOffset,
                                    getter_AddRefs(insertTxn));
    txn = insertTxn;
  }
  if (NS_FAILED(result)) return result;

  // let listeners know whats up
  PRInt32 i;
  nsIEditActionListener *listener;
  if (mActionListeners)
  {
    for (i = 0; i < mActionListeners->Count(); i++)
    {
      listener = (nsIEditActionListener *)mActionListeners->ElementAt(i);
      if (listener)
        listener->WillInsertText(aTextNode, aOffset, aStringToInsert);
    }
  }
  
  // XXX we may not need these view batches anymore.  This is handled at a higher level now I believe
  BeginUpdateViewBatch();
  result = DoTransaction(txn);
  EndUpdateViewBatch();

  mRangeUpdater.SelAdjInsertText(aTextNode, aOffset, aStringToInsert);
  
  // let listeners know what happened
  if (mActionListeners)
  {
    for (i = 0; i < mActionListeners->Count(); i++)
    {
      listener = (nsIEditActionListener *)mActionListeners->ElementAt(i);
      if (listener)
        listener->DidInsertText(aTextNode, aOffset, aStringToInsert, result);
    }
  }

  // Added some cruft here for bug 43366.  Layout was crashing because we left an 
  // empty text node lying around in the document.  So I delete empty text nodes
  // caused by IME.  I have to mark the IME transaction as "fixed", which means
  // that furure ime txns won't merge with it.  This is because we don't want
  // future ime txns trying to put their text into a node that is no longer in
  // the document.  This does not break undo/redo, because all these txns are 
  // wrapped in a parent PlaceHolder txn, and placeholder txns are already 
  // savvy to having multiple ime txns inside them.
  
  // delete empty ime text node if there is one
  if (mInIMEMode && mIMETextNode)
  {
    PRUint32 len;
    mIMETextNode->GetLength(&len);
    if (!len)
    {
      DeleteNode(mIMETextNode);
      mIMETextNode = nsnull;
      ((IMETextTxn*)txn.get())->MarkFixed();  // mark the ime txn "fixed"
    }
  }
  
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 368 of file nsEditor.cpp.

{
  NS_ENSURE_TRUE(mDocWeak && mPresShellWeak && mKeyListenerP &&
                 mMouseListenerP && mFocusListenerP && mTextListenerP &&
                 mCompositionListenerP && mDragListenerP,
                 NS_ERROR_NOT_INITIALIZED);

  nsCOMPtr<nsIDOMEventReceiver> erP = GetDOMEventReceiver();

  if (!erP) {
    RemoveEventListeners();
    return NS_ERROR_FAILURE;
  }

  nsresult rv = NS_OK;

  // register the event listeners with the listener manager
  nsCOMPtr<nsIDOMEventGroup> sysGroup;
  erP->GetSystemEventGroup(getter_AddRefs(sysGroup));
  nsCOMPtr<nsIEventListenerManager> elmP;
  erP->GetListenerManager(getter_AddRefs(elmP));

  if (sysGroup && elmP)
  {
    rv = elmP->AddEventListenerByType(mKeyListenerP,
                                      NS_LITERAL_STRING("keypress"),
                                      NS_EVENT_FLAG_BUBBLE |
                                      NS_PRIV_EVENT_UNTRUSTED_PERMITTED,
                                      sysGroup);
    NS_ASSERTION(NS_SUCCEEDED(rv),
                 "failed to register key listener in system group");
  }

  rv |= erP->AddEventListenerByIID(mMouseListenerP,
                                   NS_GET_IID(nsIDOMMouseListener));

  rv |= erP->AddEventListenerByIID(mFocusListenerP,
                                   NS_GET_IID(nsIDOMFocusListener));

  rv |= erP->AddEventListenerByIID(mTextListenerP,
                                   NS_GET_IID(nsIDOMTextListener));

  rv |= erP->AddEventListenerByIID(mCompositionListenerP,
                                   NS_GET_IID(nsIDOMCompositionListener));

  rv |= erP->AddEventListenerByIID(mDragListenerP,
                                   NS_GET_IID(nsIDOMDragListener));

  if (NS_FAILED(rv))
  {
    NS_ERROR("failed to register some event listeners");

    RemoveEventListeners();
  }

  return rv;
}

Here is the call graph for this function:

PRBool nsEditor::IsBlockNode ( nsIDOMNode aNode) [protected, virtual]

Reimplemented in nsHTMLEditor.

Definition at line 3937 of file nsEditor.cpp.

{
  // stub to be overridden in nsHTMLEditor.
  // screwing around with the class heirarchy here in order
  // to not duplicate the code in GetNextNode/GetPrevNode
  // across both nsEditor/nsHTMLEditor.  
  return PR_FALSE;
}

Here is the caller graph for this function:

returns PR_TRUE if aNode is a container

Definition at line 4033 of file nsEditor.cpp.

{
  if (!aNode) return PR_FALSE;
  nsAutoString stringTag;
  nsresult res = aNode->GetNodeName(stringTag);
  if (NS_FAILED(res)) return PR_FALSE;

  PRInt32 tagEnum;
  // XXX Should this handle #cdata-section too?
  if (stringTag.EqualsLiteral("#text")) {
    tagEnum = eHTMLTag_text;
  }
  else {
    tagEnum = sParserService->HTMLStringTagToId(stringTag);
  }

  return mDTD->IsContainer(tagEnum);
}

Here is the call graph for this function:

Here is the caller graph for this function:

returns PR_TRUE if aNode is a descendant of our root node

Definition at line 4011 of file nsEditor.cpp.

{
  if (!inNode) return PR_FALSE;
  nsIDOMElement *rootElement = GetRoot();
  if (!rootElement) return PR_FALSE;
  nsCOMPtr<nsIDOMNode> root = do_QueryInterface(rootElement);

  if (inNode == root.get()) return PR_TRUE;
  
  nsCOMPtr<nsIDOMNode> parent, node = do_QueryInterface(inNode);
  
  do
  {
    node->GetParentNode(getter_AddRefs(parent));
    if (parent == root) return PR_TRUE;
    node = parent;
  } while (parent);
  
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

returns PR_TRUE if aNode is an editable node

Definition at line 4064 of file nsEditor.cpp.

{
  if (!aNode) return PR_FALSE;
  nsCOMPtr<nsIPresShell> shell;
  GetPresShell(getter_AddRefs(shell));
  if (!shell)  return PR_FALSE;

  if (IsMozEditorBogusNode(aNode)) return PR_FALSE;
  
  // see if it has a frame.  If so, we'll edit it.
  // special case for textnodes: frame must have width.
  nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
  if (content)
  {
    nsIFrame *resultFrame;
    nsresult result = shell->GetPrimaryFrameFor(content, &resultFrame);
    if (NS_FAILED(result) || !resultFrame)   // if it has no frame, it is not editable
      return PR_FALSE;
    nsCOMPtr<nsITextContent> text(do_QueryInterface(content));
    if (!text)
      return PR_TRUE;  // not a text node; has a frame
    if (resultFrame->GetStateBits() & NS_FRAME_IS_DIRTY) // we can only trust width data for undirty frames
    {
      // In the past a comment said:
      //   "assume all text nodes with dirty frames are editable"
      // Nowadays we use a virtual function, that assumes TRUE
      // in the simple editor world,
      // and uses enhanced logic to find out in the HTML world.
      return IsTextInDirtyFrameVisible(aNode);
    }
    if (resultFrame->GetSize().width > 0) 
      return PR_TRUE;  // text node has width
  }
  return PR_FALSE;  // didn't pass any editability test
}

Here is the call graph for this function:

Here is the caller graph for this function:

returns PR_TRUE if content is an merely formatting whitespacce

Definition at line 4120 of file nsEditor.cpp.

{
  PRBool result = PR_FALSE;
  nsCOMPtr<nsITextContent> tc(do_QueryInterface(aContent));
  if (tc) {
    result = tc->IsOnlyWhitespace();
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4843 of file nsEditor.cpp.

                         {
  return mIsIMEComposing;
}

Here is the caller graph for this function:

returns PR_TRUE if aNode is a MozEditorBogus node

Definition at line 4101 of file nsEditor.cpp.

{
  if (!aNode)
    return PR_FALSE;

  nsCOMPtr<nsIDOMElement>element = do_QueryInterface(aNode);
  if (element)
  {
    nsAutoString val;
    (void)element->GetAttribute(kMOZEditorBogusNodeAttr, val);
    if (val.Equals(kMOZEditorBogusNodeValue)) {
      return PR_TRUE;
    }
  }
    
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEditor::IsPreformatted ( nsIDOMNode aNode,
PRBool aResult 
)

Definition at line 4412 of file nsEditor.cpp.

{
  nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
  
  if (!aResult || !content) return NS_ERROR_NULL_POINTER;
  
  nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
  if (!ps) return NS_ERROR_NOT_INITIALIZED;
  
  nsIFrame *frame;
  nsresult result = ps->GetPrimaryFrameFor(content, &frame);
  if (NS_FAILED(result)) return result;

  NS_ASSERTION(frame, "no frame, see bug #188946");
  if (!frame)
  {
    // Consider nodes without a style context to be NOT preformatted:
    // For instance, this is true of JS tags inside the body (which show
    // up as #text nodes but have no style context).
    *aResult = PR_FALSE;
    return NS_OK;
  }

  const nsStyleText* styleText = frame->GetStyleText();

  *aResult = NS_STYLE_WHITESPACE_PRE == styleText->mWhiteSpace ||
             NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == styleText->mWhiteSpace;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

returns PR_TRUE if aNode is our root node

Definition at line 3998 of file nsEditor.cpp.

{
  if (!inNode)
    return PR_FALSE;

  nsIDOMElement *rootElement = GetRoot();

  nsCOMPtr<nsIDOMNode> rootNode = do_QueryInterface(rootElement);

  return inNode == rootNode;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in nsHTMLEditor.

Definition at line 4053 of file nsEditor.cpp.

{
  // virtual method
  //
  // If this is a simple non-html editor,
  // the best we can do is to assume it's visible.

  return PR_TRUE;
}

Here is the caller graph for this function:

PRBool nsEditor::IsTextNode ( nsIDOMNode aNode) [static]

Definition at line 4285 of file nsEditor.cpp.

{
  if (!aNode)
  {
    NS_NOTREACHED("null node passed to IsTextNode()");
    return PR_FALSE;
  }
  
  PRUint16 nodeType;
  aNode->GetNodeType(&nodeType);
  return (nodeType == nsIDOMNode::TEXT_NODE);
}

Definition at line 4266 of file nsEditor.cpp.

{
  if (!aNode)
  {
    NS_NOTREACHED("null node passed to IsTextOrElementNode()");
    return PR_FALSE;
  }
  
  PRUint16 nodeType;
  aNode->GetNodeType(&nodeType);
  return ((nodeType == nsIDOMNode::ELEMENT_NODE) || (nodeType == nsIDOMNode::TEXT_NODE));
}

Here is the caller graph for this function:

nsresult nsEditor::JoinNodeDeep ( nsIDOMNode aLeftNode,
nsIDOMNode aRightNode,
nsCOMPtr< nsIDOMNode > *  aOutJoinNode,
PRInt32 outOffset 
)

Definition at line 4531 of file nsEditor.cpp.

{
  if (!aLeftNode || !aRightNode || !aOutJoinNode || !outOffset) return NS_ERROR_NULL_POINTER;

  // while the rightmost children and their descendants of the left node 
  // match the leftmost children and their descendants of the right node
  // join them up.  Can you say that three times fast?
  
  nsCOMPtr<nsIDOMNode> leftNodeToJoin = do_QueryInterface(aLeftNode);
  nsCOMPtr<nsIDOMNode> rightNodeToJoin = do_QueryInterface(aRightNode);
  nsCOMPtr<nsIDOMNode> parentNode,tmp;
  nsresult res = NS_OK;
  
  rightNodeToJoin->GetParentNode(getter_AddRefs(parentNode));
  
  while (leftNodeToJoin && rightNodeToJoin && parentNode &&
          NodesSameType(leftNodeToJoin, rightNodeToJoin))
  {
    // adjust out params
    PRUint32 length;
    if (IsTextNode(leftNodeToJoin))
    {
      nsCOMPtr<nsIDOMCharacterData>nodeAsText;
      nodeAsText = do_QueryInterface(leftNodeToJoin);
      nodeAsText->GetLength(&length);
    }
    else
    {
      res = GetLengthOfDOMNode(leftNodeToJoin, length);
      if (NS_FAILED(res)) return res;
    }
    
    *aOutJoinNode = rightNodeToJoin;
    *outOffset = length;
    
    // do the join
    res = JoinNodes(leftNodeToJoin, rightNodeToJoin, parentNode);
    if (NS_FAILED(res)) return res;
    
    if (IsTextNode(parentNode)) // we've joined all the way down to text nodes, we're done!
      return NS_OK;

    else
    {
      // get new left and right nodes, and begin anew
      parentNode = rightNodeToJoin;
      leftNodeToJoin = GetChildAt(parentNode, length-1);
      rightNodeToJoin = GetChildAt(parentNode, length);

      // skip over non-editable nodes
      while (leftNodeToJoin && !IsEditable(leftNodeToJoin))
      {
        leftNodeToJoin->GetPreviousSibling(getter_AddRefs(tmp));
        leftNodeToJoin = tmp;
      }
      if (!leftNodeToJoin) break;
    
      while (rightNodeToJoin && !IsEditable(rightNodeToJoin))
      {
        rightNodeToJoin->GetNextSibling(getter_AddRefs(tmp));
        rightNodeToJoin = tmp;
      }
      if (!rightNodeToJoin) break;
    }
  }
  
  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIEditor::joinNodes ( in nsIDOMNode  leftNode,
in nsIDOMNode  rightNode,
in nsIDOMNode  parent 
) [inherited]

joinNodes() takes 2 nodes and merge their content|children.

Parameters:
aLeftNodeThe left node. It will be deleted.
aRightNodeThe right node. It will remain after the join.
aParentThe parent of aExistingRightNode
                 There is no requirement that the two nodes be
                 of the same type.  However, a text node can be
                 merged only with another text node.
nsresult nsEditor::JoinNodesImpl ( nsIDOMNode aNodeToKeep,
nsIDOMNode aNodeToJoin,
nsIDOMNode aParent,
PRBool  aNodeToKeepIsFirst 
)

JoinNodes() takes 2 nodes and merge their content|children.

Parameters:
aNodeToKeepThe node that will remain after the join.
aNodeToJoinThe node that will be joined with aNodeToKeep. There is no requirement that the two nodes be of the same type.
aParentThe parent of aNodeToKeep
aNodeToKeepIsFirstif PR_TRUE, the contents|children of aNodeToKeep come before the contents|children of aNodeToJoin, otherwise their positions are switched.

Definition at line 3291 of file nsEditor.cpp.

{
  NS_ASSERTION(aNodeToKeep && aNodeToJoin && aParent, "null arg");
  nsresult result;
  if (aNodeToKeep && aNodeToJoin && aParent)
  {
    // get selection
    nsCOMPtr<nsISelection> selection;
    GetSelection(getter_AddRefs(selection));
    if (!selection) return NS_ERROR_NULL_POINTER;

    // remember some selection points
    nsCOMPtr<nsIDOMNode> selStartNode, selEndNode;
    PRInt32 selStartOffset, selEndOffset, joinOffset, keepOffset;
    result = GetStartNodeAndOffset(selection, address_of(selStartNode), &selStartOffset);
    if (NS_FAILED(result)) selStartNode = nsnull;
    result = GetEndNodeAndOffset(selection, address_of(selEndNode), &selEndOffset);
    // Joe or Kin should comment here on why the following line is not a copy/paste error
    if (NS_FAILED(result)) selStartNode = nsnull;

    nsCOMPtr<nsIDOMNode> leftNode;
    if (aNodeToKeepIsFirst)
      leftNode = aNodeToKeep;
    else
      leftNode = aNodeToJoin;

    PRUint32 firstNodeLength;
    result = GetLengthOfDOMNode(leftNode, firstNodeLength);
    if (NS_FAILED(result)) return result;
    nsCOMPtr<nsIDOMNode> parent;
    result = GetNodeLocation(aNodeToJoin, address_of(parent), &joinOffset);
    if (NS_FAILED(result)) return result;
    result = GetNodeLocation(aNodeToKeep, address_of(parent), &keepOffset);
    if (NS_FAILED(result)) return result;
    
    // if selection endpoint is between the nodes, remember it as being
    // in the one that is going away instead.  This simplifies later selection
    // adjustment logic at end of this method.
    if (selStartNode)
    {
      if (selStartNode == parent)
      {
        if (aNodeToKeepIsFirst)
        {
          if ((selStartOffset > keepOffset) && (selStartOffset <= joinOffset))
          {
            selStartNode = aNodeToJoin; 
            selStartOffset = 0;
          }
        }
        else
        {
          if ((selStartOffset > joinOffset) && (selStartOffset <= keepOffset))
          {
            selStartNode = aNodeToJoin; 
            selStartOffset = firstNodeLength;
          }
        }
      }
      if (selEndNode == parent)
      {
        if (aNodeToKeepIsFirst)
        {
          if ((selEndOffset > keepOffset) && (selEndOffset <= joinOffset))
          {
            selEndNode = aNodeToJoin; 
            selEndOffset = 0;
          }
        }
        else
        {
          if ((selEndOffset > joinOffset) && (selEndOffset <= keepOffset))
          {
            selEndNode = aNodeToJoin; 
            selEndOffset = firstNodeLength;
          }
        }
      }
    }
    // ok, ready to do join now.
    // if it's a text node, just shuffle around some text
    nsCOMPtr<nsIDOMCharacterData> keepNodeAsText( do_QueryInterface(aNodeToKeep) );
    nsCOMPtr<nsIDOMCharacterData> joinNodeAsText( do_QueryInterface(aNodeToJoin) );
    if (keepNodeAsText && joinNodeAsText)
    {
      nsAutoString rightText;
      nsAutoString leftText;
      if (aNodeToKeepIsFirst)
      {
        keepNodeAsText->GetData(leftText);
        joinNodeAsText->GetData(rightText);
      }
      else
      {
        keepNodeAsText->GetData(rightText);
        joinNodeAsText->GetData(leftText);
      }
      leftText += rightText;
      keepNodeAsText->SetData(leftText);          
    }
    else
    {  // otherwise it's an interior node, so shuffle around the children
      nsCOMPtr<nsIDOMNodeList> childNodes;
      result = aNodeToJoin->GetChildNodes(getter_AddRefs(childNodes));
      if ((NS_SUCCEEDED(result)) && (childNodes))
      {
        PRInt32 i;  // must be signed int!
        PRUint32 childCount=0;
        nsCOMPtr<nsIDOMNode> firstNode; //only used if aNodeToKeepIsFirst is false
        childNodes->GetLength(&childCount);
        if (!aNodeToKeepIsFirst)
        { // remember the first child in aNodeToKeep, we'll insert all the children of aNodeToJoin in front of it
          result = aNodeToKeep->GetFirstChild(getter_AddRefs(firstNode));  
          // GetFirstChild returns nsnull firstNode if aNodeToKeep has no children, that's ok.
        }
        nsCOMPtr<nsIDOMNode> resultNode;
        // have to go through the list backwards to keep deletes from interfering with iteration
        nsCOMPtr<nsIDOMNode> previousChild;
        for (i=childCount-1; ((NS_SUCCEEDED(result)) && (0<=i)); i--)
        {
          nsCOMPtr<nsIDOMNode> childNode;
          result = childNodes->Item(i, getter_AddRefs(childNode));
          if ((NS_SUCCEEDED(result)) && (childNode))
          {
            if (aNodeToKeepIsFirst)
            { // append children of aNodeToJoin
              //was result = aNodeToKeep->AppendChild(childNode, getter_AddRefs(resultNode));
              result = aNodeToKeep->InsertBefore(childNode, previousChild, getter_AddRefs(resultNode));
              previousChild = do_QueryInterface(childNode);
            }
            else
            { // prepend children of aNodeToJoin
              result = aNodeToKeep->InsertBefore(childNode, firstNode, getter_AddRefs(resultNode));
              firstNode = do_QueryInterface(childNode);
            }
          }
        }
      }
      else if (!childNodes) {
        result = NS_ERROR_NULL_POINTER;
      }
    }
    if (NS_SUCCEEDED(result))
    { // delete the extra node
      nsCOMPtr<nsIDOMNode> resultNode;
      result = aParent->RemoveChild(aNodeToJoin, getter_AddRefs(resultNode));
      
      if (GetShouldTxnSetSelection())
      {
        // editor wants us to set selection at join point
        selection->Collapse(aNodeToKeep, firstNodeLength);
      }
      else if (selStartNode)
      {
        // and adjust the selection if needed
        // HACK: this is overly simplified - multi-range selections need more work than this
        PRBool bNeedToAdjust = PR_FALSE;
        
        // check to see if we joined nodes where selection starts
        if (selStartNode.get() == aNodeToJoin)
        {
          bNeedToAdjust = PR_TRUE;
          selStartNode = aNodeToKeep;
          if (aNodeToKeepIsFirst)
          {
            selStartOffset += firstNodeLength;
          }
        }
        else if ((selStartNode.get() == aNodeToKeep) && !aNodeToKeepIsFirst)
        {
          bNeedToAdjust = PR_TRUE;
          selStartOffset += firstNodeLength;
        }
                
        // check to see if we joined nodes where selection ends
        if (selEndNode.get() == aNodeToJoin)
        {
          bNeedToAdjust = PR_TRUE;
          selEndNode = aNodeToKeep;
          if (aNodeToKeepIsFirst)
          {
            selEndOffset += firstNodeLength;
          }
        }
        else if ((selEndNode.get() == aNodeToKeep) && !aNodeToKeepIsFirst)
        {
          bNeedToAdjust = PR_TRUE;
          selEndOffset += firstNodeLength;
        }
        
        // adjust selection if needed
        if (bNeedToAdjust)
        {
          selection->Collapse(selStartNode,selStartOffset);
          selection->Extend(selEndNode,selEndOffset);          
        }
      }
    }
  }
  else
    result = NS_ERROR_INVALID_ARG;

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIEditor::markNodeDirty ( in nsIDOMNode  node) [inherited]

markNodeDirty() sets a special dirty attribute on the node.

Usually this will be called immediately after creating a new node.

Parameters:
aNodeThe node for which to insert formatting.
nsresult nsEditor::MoveNode ( nsIDOMNode aNode,
nsIDOMNode aParent,
PRInt32  aOffset 
)

Definition at line 1839 of file nsEditor.cpp.

{
  if (!aNode || !aParent)
    return NS_ERROR_NULL_POINTER;

  nsCOMPtr<nsIDOMNode> oldParent;
  PRInt32 oldOffset;
  nsresult res = GetNodeLocation(aNode, address_of(oldParent), &oldOffset);
  
  if (aOffset == -1)
  {
    PRUint32 unsignedOffset;
    // magic value meaning "move to end of aParent"
    res = GetLengthOfDOMNode(aParent, unsignedOffset);
    if (NS_FAILED(res)) return res;
    aOffset = (PRInt32)unsignedOffset;
  }
  
  // don't do anything if it's already in right place
  if ((aParent == oldParent.get()) && (oldOffset == aOffset)) return NS_OK;
  
  // notify our internal selection state listener
  nsAutoMoveNodeSelNotify selNotify(mRangeUpdater, oldParent, oldOffset, aParent, aOffset);
  
  // need to adjust aOffset if we are moving aNode further along in its current parent
  if ((aParent == oldParent.get()) && (oldOffset < aOffset)) 
  {
    aOffset--;  // this is because when we delete aNode, it will make the offsets after it off by one
  }

  // put aNode in new parent
  res = DeleteNode(aNode);
  if (NS_FAILED(res)) return res;
  return InsertNode(aNode, aParent, aOffset);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool nsEditor::NodeIsType ( nsIDOMNode aNode,
nsIAtom aTag 
) [inline, static]

returns PR_TRUE if aNode is of the type implied by aTag

Definition at line 473 of file nsEditor.h.

  {
    return GetTag(aNode) == aTag;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool nsEditor::NodeIsTypeString ( nsIDOMNode aNode,
const nsAString &  aTag 
) [inline, static]

Definition at line 479 of file nsEditor.h.

  {
    nsIAtom *nodeAtom = GetTag(aNode);
    return nodeAtom && nodeAtom->Equals(aTag);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsEditor::NodesSameType ( nsIDOMNode aNode1,
nsIDOMNode aNode2 
) [virtual]

Reimplemented in nsHTMLEditor.

Definition at line 4251 of file nsEditor.cpp.

{
  if (!aNode1 || !aNode2) 
  {
    NS_NOTREACHED("null node passed to nsEditor::NodesSameType()");
    return PR_FALSE;
  }
  
  return GetTag(aNode1) == GetTag(aNode2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2977 of file nsEditor.cpp.

{
  if (!mDocStateListeners)
    return NS_OK;    // maybe there just aren't any.
 
  PRUint32 numListeners;
  nsresult rv = mDocStateListeners->Count(&numListeners);
  if (NS_FAILED(rv)) return rv;

  PRUint32 i;
  switch (aNotificationType)
  {
    case eDocumentCreated:
      for (i = 0; i < numListeners;i++)
      {
        nsCOMPtr<nsIDocumentStateListener> thisListener =
          do_QueryElementAt(mDocStateListeners, i);
        if (thisListener)
        {
          rv = thisListener->NotifyDocumentCreated();
          if (NS_FAILED(rv))
            break;
        }
      }
      break;
      
    case eDocumentToBeDestroyed:
      for (i = 0; i < numListeners;i++)
      {
        nsCOMPtr<nsIDocumentStateListener> thisListener =
          do_QueryElementAt(mDocStateListeners, i);
        if (thisListener)
        {
          rv = thisListener->NotifyDocumentWillBeDestroyed();
          if (NS_FAILED(rv))
            break;
        }
      }
      break;
  
    case eDocumentStateChanged:
      {
        PRBool docIsDirty;
        rv = GetDocumentModified(&docIsDirty);
        if (NS_FAILED(rv)) return rv;
        
        if (docIsDirty == mDocDirtyState)
          return NS_OK;
        
        mDocDirtyState = (PRInt8)docIsDirty;
        
        for (i = 0; i < numListeners;i++)
        {
          nsCOMPtr<nsIDocumentStateListener> thisListener =
            do_QueryElementAt(mDocStateListeners, i);
          if (thisListener)
          {
            rv = thisListener->NotifyDocumentStateChanged(mDocDirtyState);
            if (NS_FAILED(rv))
              break;
          }
        }
      }
      break;
    
    default:
      NS_NOTREACHED("Unknown notification");
  }

  return rv;
}

Here is the call graph for this function:

Definition at line 1921 of file nsEditor.cpp.

{
  if (mEditorObservers)
  {
    PRInt32 i;
    nsIEditorObserver *observer;
    for (i = 0; i < mEditorObservers->Count(); i++)
    {
      observer = (nsIEditorObserver*)mEditorObservers->ElementAt(i);
      if (observer)
        observer->EditAction();
    }
  }
}

Here is the call graph for this function:

Notify for IME when the editor lost focus.

Notify for IME when the editor got focus.

void nsIEditor::outputToStream ( in nsIOutputStream  aStream,
in AString  formatType,
in ACString  charsetOverride,
in unsigned long  flags 
) [inherited]
AString nsIEditor::outputToString ( in AString  formatType,
in unsigned long  flags 
) [inherited]

Output methods: aFormatType is a mime type, like text/plain.

void nsIEditor::paste ( in long  aSelectionType) [inherited]

paste the text in the OS clipboard at the cursor position, replacing the selected text (if any)

void nsIEditor::postCreate ( ) [inherited]

postCreate should be called after Init, and is the time that the editor tells its documentStateObservers that the document has been created.

void nsIEditor::preDestroy ( ) [inherited]

preDestroy is called before the editor goes away, and gives the editor a chance to tell its documentStateObservers that the document is going away.

Definition at line 2111 of file nsEditor.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

queryComposition() Get the composition position

void nsIEditor::redo ( in unsigned long  count) [inherited]

redo reverses the effects of the last Undo operation It is provided here so clients need no knowledge of whether the editor has a transaction manager or not.

If a transaction manager is present, it is told to redo and the result of the previously undone transaction is reapplied to the document. If no transaction is available for Redo, or if the document has no transaction manager, the Redo request is ignored and an error NS_ERROR_NOT_AVAILABLE is returned.

void nsIEditor::removeAttribute ( in nsIDOMElement  aElement,
in AString  aAttribute 
) [inherited]

removeAttribute() deletes aAttribute from the attribute list of aElement.

If aAttribute is not an attribute of aElement, nothing is done.

Parameters:
aElementthe content element to operate on
aAttributethe string representation of the attribute to get
void nsIEditor::removeAttributeOrEquivalent ( in nsIDOMElement  element,
in DOMString  sourceAttrName,
in boolean  aSuppressTransaction 
) [inherited]

Definition at line 1749 of file nsEditor.cpp.

{
  if (!inNode)
    return NS_ERROR_NULL_POINTER;
  nsCOMPtr<nsIDOMNode> parent;
  PRInt32 offset;
  
  nsresult res = GetNodeLocation(inNode, address_of(parent), &offset);
  if (NS_FAILED(res)) return res;
  
  // loop through the child nodes of inNode and promote them
  // into inNode's parent.
  PRBool bHasMoreChildren;
  inNode->HasChildNodes(&bHasMoreChildren);
  nsCOMPtr<nsIDOMNodeList> nodeList;
  res = inNode->GetChildNodes(getter_AddRefs(nodeList));
  if (NS_FAILED(res)) return res;
  if (!nodeList) return NS_ERROR_NULL_POINTER;
  PRUint32 nodeOrigLen;
  nodeList->GetLength(&nodeOrigLen);

  // notify our internal selection state listener
  nsAutoRemoveContainerSelNotify selNotify(mRangeUpdater, inNode, parent, offset, nodeOrigLen);
                                   
  nsCOMPtr<nsIDOMNode> child;
  while (bHasMoreChildren)
  {
    inNode->GetLastChild(getter_AddRefs(child));
    res = DeleteNode(child);
    if (NS_FAILED(res)) return res;
    res = InsertNode(child, parent, offset);
    if (NS_FAILED(res)) return res;
    inNode->HasChildNodes(&bHasMoreChildren);
  }
  return DeleteNode(inNode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Remove a DocumentStateListener to the editors list of doc state listeners.

Remove an EditActionListener from the editor's list of listeners.

Remove an EditorObserver from the editor's list of observers.

void nsEditor::RemoveEventListeners ( ) [protected, virtual]

Reimplemented in nsHTMLEditor.

Definition at line 427 of file nsEditor.cpp.

{
  if (!mDocWeak)
  {
    return;
  }

  nsCOMPtr<nsIDOMEventReceiver> erP = GetDOMEventReceiver();

  if (erP)
  {
    // unregister the event listeners with the DOM event reveiver

    if (mKeyListenerP)
    {
      nsCOMPtr<nsIDOMEventGroup> sysGroup;
      erP->GetSystemEventGroup(getter_AddRefs(sysGroup));
      nsCOMPtr<nsIEventListenerManager> elmP;
      erP->GetListenerManager(getter_AddRefs(elmP));
      if (sysGroup && elmP)
      {
        elmP->RemoveEventListenerByType(mKeyListenerP,
                                        NS_LITERAL_STRING("keypress"),
                                        NS_EVENT_FLAG_BUBBLE |
                                        NS_PRIV_EVENT_UNTRUSTED_PERMITTED,
                                        sysGroup);
      }
    }

    if (mMouseListenerP)
    {
      erP->RemoveEventListenerByIID(mMouseListenerP,
                                    NS_GET_IID(nsIDOMMouseListener));
    }

    if (mFocusListenerP)
    {
      erP->RemoveEventListenerByIID(mFocusListenerP,
                                    NS_GET_IID(nsIDOMFocusListener));
    }

    if (mTextListenerP)
    {
      erP->RemoveEventListenerByIID(mTextListenerP,
                                    NS_GET_IID(nsIDOMTextListener));
    }

    if (mCompositionListenerP)
    {
      erP->RemoveEventListenerByIID(mCompositionListenerP,
                                    NS_GET_IID(nsIDOMCompositionListener));
    }

    if (mDragListenerP)
    {
      erP->RemoveEventListenerByIID(mDragListenerP,
                                    NS_GET_IID(nsIDOMDragListener));
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEditor::ReplaceContainer ( nsIDOMNode inNode,
nsCOMPtr< nsIDOMNode > *  outNode,
const nsAString &  aNodeType,
const nsAString *  aAttribute = nsnull,
const nsAString *  aValue = nsnull,
PRBool  aCloneAttributes = PR_FALSE 
)

Definition at line 1682 of file nsEditor.cpp.

{
  if (!inNode || !outNode)
    return NS_ERROR_NULL_POINTER;
  nsCOMPtr<nsIDOMNode> parent;
  PRInt32 offset;
  nsresult res = GetNodeLocation(inNode, address_of(parent), &offset);
  if (NS_FAILED(res)) return res;

  // create new container
  nsCOMPtr<nsIContent> newContent;

  //new call to use instead to get proper HTML element, bug# 39919
  res = CreateHTMLContent(aNodeType, getter_AddRefs(newContent));
  nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(newContent);
  if (NS_FAILED(res)) return res;
    *outNode = do_QueryInterface(elem);
  
  // set attribute if needed
  if (aAttribute && aValue && !aAttribute->IsEmpty())
  {
    res = elem->SetAttribute(*aAttribute, *aValue);
    if (NS_FAILED(res)) return res;
  }
  if (aCloneAttributes)
  {
    nsCOMPtr<nsIDOMNode>newNode = do_QueryInterface(elem);
    res = CloneAttributes(newNode, inNode);
    if (NS_FAILED(res)) return res;
  }
  
  // notify our internal selection state listener
  // (Note: A nsAutoSelectionReset object must be created
  //  before calling this to initialize mRangeUpdater)
  nsAutoReplaceContainerSelNotify selStateNotify(mRangeUpdater, inNode, *outNode);
  
  nsCOMPtr<nsIDOMNode> child;
  PRBool bHasMoreChildren;
  inNode->HasChildNodes(&bHasMoreChildren);
  while (bHasMoreChildren)
  {
    inNode->GetFirstChild(getter_AddRefs(child));
    res = DeleteNode(child);
    if (NS_FAILED(res)) return res;
    res = InsertNode(child, *outNode, -1);
    if (NS_FAILED(res)) return res;
    inNode->HasChildNodes(&bHasMoreChildren);
  }

  // insert new container into tree
  res = InsertNode( *outNode, parent, offset);
  if (NS_FAILED(res)) return res;
  
  // delete old container
  return DeleteNode(inNode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

to be used ONLY when we need to override the doc's modification state (such as when it's saved).

Definition at line 2119 of file nsEditor.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsEditor::ScrollSelectionIntoView ( PRBool  aScrollToAnchor) [protected]

helper method for scrolling the selection into view after an edit operation.

aScrollToAnchor should be PR_TRUE if you want to scroll to the point where the selection was started. If PR_FALSE, it attempts to scroll the end of the selection into view.

Editor methods should call this method instead of the versions in the various selection interfaces, since this version makes sure that the editor's sync/async settings for reflowing, painting, and scrolling match.

Definition at line 2694 of file nsEditor.cpp.

{
  nsCOMPtr<nsISelectionController> selCon;
  if (NS_SUCCEEDED(GetSelectionController(getter_AddRefs(selCon))) && selCon)
  {
    PRInt16 region = nsISelectionController::SELECTION_FOCUS_REGION;

    if (aScrollToAnchor)
      region = nsISelectionController::SELECTION_ANCHOR_REGION;

    PRBool syncScroll = PR_TRUE;
    PRUint32 flags = 0;

    if (NS_SUCCEEDED(GetFlags(&flags)))
    {
      // If the editor is relying on asynchronous reflows, we have
      // to use asynchronous requests to scroll, so that the scrolling happens
      // after reflow requests are processed.

      syncScroll = !(flags & nsIPlaintextEditor::eEditorUseAsyncUpdatesMask);
    }

    selCon->ScrollSelectionIntoView(nsISelectionController::SELECTION_NORMAL,
                                    region, syncScroll);
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIEditor::selectAll ( ) [inherited]

sets the document selection to the entire contents of the document

make the given selection span the entire document

Reimplemented in nsHTMLEditor, and nsPlaintextEditor.

Definition at line 2921 of file nsEditor.cpp.

{
  if (!aSelection) { return NS_ERROR_NULL_POINTER; }

  nsIDOMElement *rootElement = GetRoot();
  if (!rootElement) { return NS_ERROR_NOT_INITIALIZED; }

  return aSelection->SelectAllChildren(rootElement);
}

Here is the call graph for this function:

void nsIEditor::setAttribute ( in nsIDOMElement  aElement,
in AString  attributestr,
in AString  attvalue 
) [inherited]

setAttribute() sets the attribute of aElement.

No checking is done to see if aAttribute is a legal attribute of the node, or if aValue is a legal value of aAttribute.

Parameters:
aElementthe content element to operate on
aAttributethe string representation of the attribute to set
aValuethe value to set aAttribute to
void nsIEditor::setAttributeOrEquivalent ( in nsIDOMElement  element,
in AString  sourceAttrName,
in AString  sourceAttrValue,
in boolean  aSuppressTransaction 
) [inherited]
void nsIEditorIMESupport::setCompositionString ( in DOMString  aCompositionString,
in nsIPrivateTextRangeListPtr  aTextRange,
in nsTextEventReplyPtr  aReply 
) [inherited]

setCompositionString() Sets the inline input composition string.

beginComposition must be called prior to this.

Definition at line 4812 of file nsEditor.cpp.

                           {  
  // We set mIsIMEComposing according to mIMETextRangeList.
  nsCOMPtr<nsIPrivateTextRange> rangePtr;
  PRUint16 listlen, type;

  mIsIMEComposing = PR_FALSE;
  nsresult result = mIMETextRangeList->GetLength(&listlen);
  if (NS_FAILED(result)) return;

  for (PRUint16 i = 0; i < listlen; i++)
  {
      result = mIMETextRangeList->Item(i, getter_AddRefs(rangePtr));
      if (NS_FAILED(result)) continue;
      result = rangePtr->GetRangeType(&type);
      if (NS_FAILED(result)) continue;
      if ( type == nsIPrivateTextRange::TEXTRANGE_RAWINPUT ||
           type == nsIPrivateTextRange::TEXTRANGE_CONVERTEDTEXT ||
           type == nsIPrivateTextRange::TEXTRANGE_SELECTEDRAWTEXT ||
           type == nsIPrivateTextRange::TEXTRANGE_SELECTEDCONVERTEDTEXT )
      {
        mIsIMEComposing = PR_TRUE;
#ifdef DEBUG_IME
        printf("nsEditor::mIsIMEComposing = PR_TRUE\n");
#endif
        break;
      }
  }
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Set the flag that prevents insertElementTxn from changing the selection.

Parameters:
shouldSet false to suppress changing the selection; i.e., before using InsertElement() to insert under <head> element WARNING: You must be very careful to reset back to PR_TRUE after setting PR_FALSE, else selection/caret is trashed for further editing.

Called when the user manually overrides the spellchecking state for this editor.

Parameters:
enableThe new state of spellchecking in this editor, as requested by the user.
void nsIEditor::splitNode ( in nsIDOMNode  existingRightNode,
in long  offset,
out nsIDOMNode  newLeftNode 
) [inherited]

splitNode() creates a new node identical to an existing node, and split the contents between the two nodes

Parameters:
aExistingRightNodethe node to split. It will become the new node's next sibling.
aOffsetthe offset of aExistingRightNode's content|children to do the split at
aNewLeftNode[OUT] the new node resulting from the split, becomes aExistingRightNode's previous sibling.
nsresult nsEditor::SplitNodeDeep ( nsIDOMNode aNode,
nsIDOMNode aSplitPointParent,
PRInt32  aSplitPointOffset,
PRInt32 outOffset,
PRBool  aNoEmptyContainers = PR_FALSE,
nsCOMPtr< nsIDOMNode > *  outLeftN