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 | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Types | Friends
nsHTMLEditor Class Reference

The HTML editor implementation. More...

#include <nsHTMLEditor.h>

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

List of all members.

Public Types

enum  OperationID {
  kOpInsertBreak = 3000, kOpMakeList = 3001, kOpIndent = 3002, kOpOutdent = 3003,
  kOpAlign = 3004, kOpMakeBasicBlock = 3005, kOpRemoveList = 3006, kOpMakeDefListItem = 3007,
  kOpInsertElement = 3008, kOpInsertQuotation = 3009, kOpSetTextProperty = 3010, kOpRemoveTextProperty = 3011,
  kOpHTMLPaste = 3012, kOpLoadHTML = 3013, kOpResetTextProperties = 3014, kOpSetAbsolutePosition = 3015,
  kOpRemoveAbsolutePosition = 3016, kOpDecreaseZIndex = 3017, kOpIncreaseZIndex = 3018
}
enum  ResizingRequestID { kX = 0, kY = 1, kWidth = 2, kHeight = 3 }
enum  { eTypedText, eTypedBR, eTypedBreak }
enum  IterDirection { kIterForward, kIterBackward }
typedef short EDirection
typedef short EAlignment
typedef short EResizerLocation

Public Member Functions

NS_DECL_ISUPPORTS_INHERITED nsHTMLEditor ()
virtual ~nsHTMLEditor ()
NS_IMETHODIMP HandleKeyPress (nsIDOMKeyEvent *aKeyEvent)
NS_IMETHOD GetIsDocumentEditable (PRBool *aIsDocumentEditable)
NS_IMETHODIMP BeginningOfDocument ()
NS_DECL_NSIHTMLEDITOR
NS_DECL_NSIHTMLOBJECTRESIZER
NS_DECL_NSIHTMLABSPOSEDITOR
NS_DECL_NSIHTMLINLINETABLEEDITOR
NS_IMETHOD 
CopyLastEditableChildStyles (nsIDOMNode *aPreviousBlock, nsIDOMNode *aNewBlock, nsIDOMNode **aOutBrNode)
NS_IMETHOD LoadHTML (const nsAString &aInputString)
NS_IMETHOD GetParentBlockTags (nsStringArray *aTagList, PRBool aGetLists)
nsresult GetCSSBackgroundColorState (PRBool *aMixed, nsAString &aOutColor, PRBool aBlockLevel)
NS_IMETHOD GetHTMLBackgroundColorState (PRBool *aMixed, nsAString &outColor)
NS_IMETHOD GetHighlightColor (PRBool *mixed, PRUnichar **_retval)
NS_IMETHOD GetNextElementByTagName (nsIDOMElement *aCurrentElement, const nsAString *aTagName, nsIDOMElement **aReturn)
NS_IMETHOD AddStyleSheet (const nsAString &aURL)
NS_IMETHOD ReplaceStyleSheet (const nsAString &aURL)
NS_IMETHOD RemoveStyleSheet (const nsAString &aURL)
NS_IMETHOD AddOverrideStyleSheet (const nsAString &aURL)
NS_IMETHOD ReplaceOverrideStyleSheet (const nsAString &aURL)
NS_IMETHOD RemoveOverrideStyleSheet (const nsAString &aURL)
NS_IMETHOD EnableStyleSheet (const nsAString &aURL, PRBool aEnable)
NS_DECL_NSIEDITORMAILSUPPORT
NS_IMETHOD 
InsertTableCell (PRInt32 aNumber, PRBool aAfter)
NS_IMETHOD InsertTableColumn (PRInt32 aNumber, PRBool aAfter)
NS_IMETHOD InsertTableRow (PRInt32 aNumber, PRBool aAfter)
NS_IMETHOD DeleteTable ()
NS_IMETHOD DeleteTableCell (PRInt32 aNumber)
NS_IMETHOD DeleteTableCellContents ()
NS_IMETHOD DeleteTableColumn (PRInt32 aNumber)
NS_IMETHOD DeleteTableRow (PRInt32 aNumber)
NS_IMETHOD SelectTableCell ()
NS_IMETHOD SelectBlockOfCells (nsIDOMElement *aStartCell, nsIDOMElement *aEndCell)
NS_IMETHOD SelectTableRow ()
NS_IMETHOD SelectTableColumn ()
NS_IMETHOD SelectTable ()
NS_IMETHOD SelectAllTableCells ()
NS_IMETHOD SwitchTableCellHeaderType (nsIDOMElement *aSourceCell, nsIDOMElement **aNewCell)
NS_IMETHOD JoinTableCells (PRBool aMergeNonContiguousContents)
NS_IMETHOD SplitTableCell ()
NS_IMETHOD NormalizeTable (nsIDOMElement *aTable)
NS_IMETHOD GetCellIndexes (nsIDOMElement *aCell, PRInt32 *aRowIndex, PRInt32 *aColIndex)
NS_IMETHOD GetTableSize (nsIDOMElement *aTable, PRInt32 *aRowCount, PRInt32 *aColCount)
NS_IMETHOD GetCellAt (nsIDOMElement *aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement **aCell)
NS_IMETHOD GetCellDataAt (nsIDOMElement *aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement **aCell, PRInt32 *aStartRowIndex, PRInt32 *aStartColIndex, PRInt32 *aRowSpan, PRInt32 *aColSpan, PRInt32 *aActualRowSpan, PRInt32 *aActualColSpan, PRBool *aIsSelected)
NS_IMETHOD GetFirstRow (nsIDOMElement *aTableElement, nsIDOMNode **aRowNode)
NS_IMETHOD GetNextRow (nsIDOMNode *aCurrentRowNode, nsIDOMNode **aRowNode)
NS_IMETHOD GetFirstCellInRow (nsIDOMNode *aRowNode, nsIDOMNode **aCellNode)
NS_IMETHOD GetNextCellInRow (nsIDOMNode *aCurrentCellNode, nsIDOMNode **aRowNode)
NS_IMETHOD GetLastCellInRow (nsIDOMNode *aRowNode, nsIDOMNode **aCellNode)
NS_IMETHOD SetSelectionAfterTableEdit (nsIDOMElement *aTable, PRInt32 aRow, PRInt32 aCol, PRInt32 aDirection, PRBool aSelected)
NS_IMETHOD GetSelectedOrParentTableElement (nsAString &aTagName, PRInt32 *aSelectedCount, nsIDOMElement **aTableElement)
NS_IMETHOD GetSelectedCellsType (nsIDOMElement *aElement, PRUint32 *aSelectionType)
nsresult GetCellFromRange (nsIDOMRange *aRange, nsIDOMElement **aCell)
NS_IMETHOD GetFirstSelectedCell (nsIDOMRange **aRange, nsIDOMElement **aCell)
NS_IMETHOD GetNextSelectedCell (nsIDOMRange **aRange, nsIDOMElement **aCell)
NS_IMETHOD GetFirstSelectedCellInTable (PRInt32 *aRowIndex, PRInt32 *aColIndex, nsIDOMElement **aCell)
NS_IMETHOD SetCSSBackgroundColor (const nsAString &aColor)
NS_IMETHOD SetHTMLBackgroundColor (const nsAString &aColor)
nsresult IsNextCharWhitespace (nsIDOMNode *aParentNode, PRInt32 aOffset, PRBool *outIsSpace, PRBool *outIsNBSP, nsCOMPtr< nsIDOMNode > *outNode=0, PRInt32 *outOffset=0)
nsresult IsPrevCharWhitespace (nsIDOMNode *aParentNode, PRInt32 aOffset, PRBool *outIsSpace, PRBool *outIsNBSP, nsCOMPtr< nsIDOMNode > *outNode=0, PRInt32 *outOffset=0)
nsresult EndUpdateViewBatch ()
NS_IMETHOD Init (nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags)
 prepare the editor for use
NS_IMETHOD GetFlags (PRUint32 *aFlags)
NS_IMETHOD SetFlags (PRUint32 aFlags)
NS_IMETHOD Paste (PRInt32 aSelectionType)
NS_IMETHOD CanPaste (PRInt32 aSelectionType, PRBool *aCanPaste)
NS_IMETHOD DebugUnitTests (PRInt32 *outNumTests, PRInt32 *outNumTestsFailed)
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.
virtual PRBool TagCanContainTag (const nsAString &aParentTag, const nsAString &aChildTag)
 returns PR_TRUE if aParentTag can contain a child of type aChildTag
NS_IMETHOD SelectEntireDocument (nsISelection *aSelection)
 make the given selection span the entire document
NS_IMETHOD SetAttributeOrEquivalent (nsIDOMElement *aElement, const nsAString &aAttribute, const nsAString &aValue, PRBool aSuppressTransaction)
NS_IMETHOD RemoveAttributeOrEquivalent (nsIDOMElement *aElement, const nsAString &aAttribute, PRBool aSuppressTransaction)
NS_IMETHOD CollapseAdjacentTextNodes (nsIDOMRange *aInRange)
 join together any afjacent editable text nodes in the range
virtual PRBool NodesSameType (nsIDOMNode *aNode1, nsIDOMNode *aNode2)
NS_IMETHODIMP DeleteNode (nsIDOMNode *aNode)
NS_IMETHODIMP DeleteText (nsIDOMCharacterData *aTextNode, PRUint32 aOffset, PRUint32 aLength)
NS_IMETHOD StyleSheetLoaded (nsICSSStyleSheet *aSheet, PRBool aNotify)
NS_IMETHOD TypedText (const nsAString &aString, PRInt32 aAction)
nsresult InsertNodeAtPoint (nsIDOMNode *aNode, nsCOMPtr< nsIDOMNode > *ioParent, PRInt32 *ioOffset, PRBool aNoEmptyNodes)
nsCOMPtr< nsIDOMNodeFindUserSelectAllNode (nsIDOMNode *aNode)
nsresult GetTextSelectionOffsets (nsISelection *aSelection, PRInt32 &aStartOffset, PRInt32 &aEndOffset)
 returns the absolute position of the end points of aSelection in the document as a text stream.
nsresult GetAbsoluteOffsetsForPoints (nsIDOMNode *aInStartNode, PRInt32 aInStartOffset, nsIDOMNode *aInEndNode, PRInt32 aInEndOffset, nsIDOMNode *aInCommonParentNode, PRInt32 &aOutStartOffset, PRInt32 &aEndOffset)
nsresult CollapseSelectionToDeepestNonTableFirstChild (nsISelection *aSelection, nsIDOMNode *aNode)
virtual PRBool IsTextInDirtyFrameVisible (nsIDOMNode *aNode)
nsresult IsVisTextNode (nsIDOMNode *aNode, PRBool *outIsEmptyNode, PRBool aSafeToAskFrames)
nsresult IsEmptyNode (nsIDOMNode *aNode, PRBool *outIsEmptyBlock, PRBool aMozBRDoesntCount=PR_FALSE, PRBool aListOrCellNotEmpty=PR_FALSE, PRBool aSafeToAskFrames=PR_FALSE)
nsresult IsEmptyNodeImpl (nsIDOMNode *aNode, PRBool *outIsEmptyBlock, PRBool aMozBRDoesntCount, PRBool aListOrCellNotEmpty, PRBool aSafeToAskFrames, PRBool *aSeenBR)
nsresult AddCSSStyleSheet (nsICSSStyleSheet *aSheet)
nsresult GetCSSLoader (const nsAString &aURL, nsICSSLoader **aCSSLoader)
PRBool EnableExistingStyleSheet (const nsAString &aURL)
NS_IMETHOD GetStyleSheetForURL (const nsAString &aURL, nsICSSStyleSheet **_retval)
NS_IMETHOD GetURLForStyleSheet (nsICSSStyleSheet *aStyleSheet, nsAString &aURL)
nsresult AddNewStyleSheetToList (const nsAString &aURL, nsICSSStyleSheet *aStyleSheet)
nsresult RemoveStyleSheetFromList (const nsAString &aURL)
NS_DECL_NSIPLAINTEXTEDITOR
NS_DECL_NSIEDITORMAILSUPPORT
NS_IMETHOD 
SetCompositionString (const nsAString &aCompositionString, nsIPrivateTextRangeList *aTextRange, nsTextEventReply *aReply)
NS_IMETHOD GetReconversionString (nsReconversionEventReply *aReply)
NS_IMETHOD BeginComposition (nsTextEventReply *aReply)
NS_IMETHOD GetDocumentIsEmpty (PRBool *aDocumentIsEmpty)
NS_IMETHOD DeleteSelection (EDirection aAction)
NS_IMETHOD SetDocumentCharacterSet (const nsACString &characterSet)
NS_IMETHOD Undo (PRUint32 aCount)
NS_IMETHOD Redo (PRUint32 aCount)
NS_IMETHOD Cut ()
NS_IMETHOD CanCut (PRBool *aCanCut)
NS_IMETHOD Copy ()
NS_IMETHOD CanCopy (PRBool *aCanCopy)
NS_IMETHOD CanDrag (nsIDOMEvent *aDragEvent, PRBool *aCanDrag)
NS_IMETHOD DoDrag (nsIDOMEvent *aDragEvent)
NS_IMETHOD InsertFromDrop (nsIDOMEvent *aDropEvent)
NS_IMETHOD OutputToString (const nsAString &aFormatType, PRUint32 aFlags, nsAString &aOutputString)
NS_IMETHOD OutputToStream (nsIOutputStream *aOutputStream, const nsAString &aFormatType, const nsACString &aCharsetOverride, PRUint32 aFlags)
nsresult GetTextSelectionOffsets (nsISelection *aSelection, PRUint32 &aStartOffset, PRUint32 &aEndOffset)
 Returns the absolute position of the end points of aSelection in the document as a text stream.
nsresult InsertTextAt (const nsAString &aStringToInsert, nsIDOMNode *aDestinationNode, PRInt32 aDestOffset, PRBool aDoDeleteSelection)
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)
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)
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
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 ()
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)
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
void handleKeyPress (in nsIDOMKeyEvent aKeyEvent)
 EditorKeyPress consumes a keyevent.
void insertText (in DOMString aStringToInsert)
 Inserts a string at the current location, given by the selection.
void insertLineBreak ()
 Insert a line break into the content model.
void pasteAsQuotation (in long aSelectionType)
 Paste the text in the OS clipboard at the cursor position, as a quotation (whose representation is dependant on the editor type), replacing the selected text (if any).
nsIDOMNode insertAsQuotation (in AString aQuotedText)
 Insert a string as quoted text (whose representation is dependant on the editor type), replacing the selected text (if any).
void insertTextWithQuotations (in DOMString aStringToInsert)
 Inserts a plaintext string at the current location, with special processing for lines beginning with ">", which will be treated as mail quotes and inserted as plaintext quoted blocks.
void pasteAsCitedQuotation (in AString aCitation, in long aSelectionType)
 Paste a string as quoted text, whose representation is dependant on the editor type, replacing the selected text (if any)
nsIDOMNode insertAsCitedQuotation (in AString aQuotedText, in AString aCitation, in boolean aInsertHTML)
 Insert a string as quoted text (whose representation is dependant on the editor type), replacing the selected text (if any), including, if possible, a "cite" attribute.
void rewrap (in boolean aRespectNewlines)
 Rewrap the selected part of the document, re-quoting if necessary.
void stripCites ()
 Strip any citations in the selected part of the document.
nsISupportsArray getEmbeddedObjects ()
 Get a list of IMG and OBJECT tags in the current document.
void addDefaultProperty (in nsIAtom aProperty, in AString aAttribute, in AString aValue)
 AddDefaultProperty() registers a default style property with the editor.
void removeDefaultProperty (in nsIAtom aProperty, in AString aAttribute, in AString aValue)
 RemoveDefaultProperty() unregisters a default style property with the editor.
void removeAllDefaultProperties ()
 RemoveAllDefaultProperties() unregisters all default style properties with the editor.
void setCSSInlineProperty (in nsIAtom aProperty, in AString aAttribute, in AString aValue)
 SetInlineProperty() sets the aggregate properties on the current selection.
void setInlineProperty (in nsIAtom aProperty, in AString aAttribute, in AString aValue)
void getInlineProperty (in nsIAtom aProperty, in AString aAttribute, in AString aValue, out boolean aFirst, out boolean aAny, out boolean aAll)
 getInlineProperty() gets aggregate properties of the current selection.
AString getInlinePropertyWithAttrValue (in nsIAtom aProperty, in AString aAttribute, in AString aValue, out boolean aFirst, out boolean aAny, out boolean aAll)
void removeAllInlineProperties ()
 removeAllInlineProperties() deletes all the inline properties from all text in the current selection.
void removeInlineProperty (in nsIAtom aProperty, in AString aAttribute)
 removeInlineProperty() deletes the properties from all text in the current selection.
void increaseFontSize ()
 Increase font size for text in selection by 1 HTML unit All existing text is scanned for existing <FONT size>=""> attributes so they will be incremented instead of inserting new <FONT> tag.
void decreaseFontSize ()
 Decrease font size for text in selection by 1 HTML unit All existing text is scanned for existing <FONT size>=""> attributes so they will be decreased instead of inserting new <FONT> tag.
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.
boolean nodeIsBlock (in nsIDOMNode node)
 Tests if a node is a BLOCK element according the the HTML 4.0 DTD.
void insertHTML (in AString aInputString)
 Insert some HTML source at the current location.
void pasteNoFormatting (in long aSelectionType)
 Paste the text in the OS clipboard at the cursor position, replacing the selected text (if any), but strip out any HTML styles and formatting.
void rebuildDocumentFromSource (in AString aSourceString)
 Rebuild the entire document from source HTML Needed to be able to edit HEAD and other outside-of-BODY content.
void insertHTMLWithContext (in AString aInputString, in AString aContextStr, in AString aInfoStr, in AString aFlavor, in nsIDOMDocument aSourceDoc, in nsIDOMNode aDestinationNode, in long aDestinationOffset, in boolean aDeleteSelection)
 Insert some HTML source, interpreting the string argument according to the given context.
void insertElementAtSelection (in nsIDOMElement aElement, in boolean aDeleteSelection)
 Insert an element, which may have child nodes, at the selection Used primarily to insert a new element for various insert element dialogs, but it enforces the HTML 4.0 DTD "CanContain" rules, so it should be useful for other elements.
void setDocumentTitle (in AString aTitle)
 Set the documents title.
void updateBaseURL ()
 Set the BaseURL for the document to the current URL but only if the page doesn't have a <base> tag This should be done after the document URL has changed, such as after saving a file This is used as base for relativizing link and image urls.
void selectElement (in nsIDOMElement aElement)
 Set the selection at the suppled element.
void setCaretAfterElement (in nsIDOMElement aElement)
 Create a collapsed selection just after aElement.
void setParagraphFormat (in AString aParagraphFormat)
 SetParagraphFormat Insert a block paragraph tag around selection.
AString getParagraphState (out boolean aMixed)
 getParagraphState returns what block tag paragraph format is in the selection.
AString getFontFaceState (out boolean aMixed)
 getFontFaceState returns what font face is in the selection.
AString getFontColorState (out boolean aMixed)
 getFontColorState returns what font face is in the selection.
AString getBackgroundColorState (out boolean aMixed)
 getFontColorState returns what font face is in the selection.
AString getHighlightColorState (out boolean aMixed)
 getHighlightColorState returns what the highlight color of the selection.
void getListState (out boolean aMixed, out boolean aOL, out boolean aUL, out boolean aDL)
 getListState returns what list type is in the selection.
void getListItemState (out boolean aMixed, out boolean aLI, out boolean aDT, out boolean aDD)
 getListItemState returns what list item type is in the selection.
void getAlignment (out boolean aMixed, out short aAlign)
 getAlignment returns what alignment is in the selection.
void getIndentState (out boolean aCanIndent, out boolean aCanOutdent)
 Document me!
void makeOrChangeList (in AString aListType, in boolean entireList, in AString aBulletType)
 Document me!
void removeList (in AString aListType)
 Document me!
void indent (in AString aIndent)
 Document me!
void align (in AString aAlign)
 Document me!
nsIDOMElement getElementOrParentByTagName (in AString aTagName, in nsIDOMNode aNode)
 Return the input node or a parent matching the given aTagName, starting the search at the supplied node.
nsIDOMElement getSelectedElement (in AString aTagName)
 Return an element only if it is the only node selected, such as an image, horizontal rule, etc.
AString getHeadContentsAsHTML ()
 Output the contents of the <HEAD> section as text/HTML format.
void replaceHeadContentsWithHTML (in AString aSourceToInsert)
 Replace all children of <HEAD> with string of HTML source.
nsIDOMElement createElementWithDefaults (in AString aTagName)
 Return a new element with default attribute values.
void insertLinkAroundSelection (in nsIDOMElement aAnchorElement)
 Insert an link element as the parent of the current selection.
void setBackgroundColor (in AString aColor)
 Set the value of the "bgcolor" attribute on the document's <body> element.
void setBodyAttribute (in AString aAttr, in AString aValue)
 Set an attribute on the document's <body> element such as text, link, background colors.
void ignoreSpuriousDragEvent (in boolean aIgnoreSpuriousDragEvent)
 XXX Used to suppress spurious drag/drop events to workaround bug 50703 Don't use this method! It will go away after first release!
nsISupportsArray getLinkedObjects ()
 Find all the nodes in the document which contain references to outside URIs (e.g.
void addInsertionListener (in nsIContentFilter inFilter)
 Add listener for insertion override.
void removeInsertionListener (in nsIContentFilter inFilter)
 Remove listener for insertion override.
nsIDOMElement createAnonymousElement (in AString aTag, in nsIDOMNode aParentNode, in AString aAnonClass, in boolean aIsCreatedHidden)
 Returns an anonymous nsDOMElement of type aTag, child of aParentNode.
nsIDOMElement getSelectionContainer ()
 returns the deepest container of the selection
void checkSelectionStateForAnonymousButtons (in nsISelection aSelection)
 Checks if the anonymous nodes created by the HTML editor have to be refreshed or hidden depending on a possible new state of the selection.
boolean isAnonymousElement (in nsIDOMElement aElement)
void showResizers (in nsIDOMElement aResizedElement)
 Shows active resizers around an element's frame.
void hideResizers ()
 Hide resizers if they are visible.
void refreshResizers ()
 Refresh visible resizers.
void mouseDown (in long aX, in long aY, in nsIDOMElement aTarget)
 event callback when a mouse button is pressed
void mouseUp (in long aX, in long aY, in nsIDOMElement aTarget)
 event callback when a mouse button is released
void mouseMove (in nsIDOMEvent aMouseEvent)
 event callback when the mouse pointer is moved
void addObjectResizeEventListener (in nsIHTMLObjectResizeListener aListener)
 Creates a resize listener that can be used to get notifications that the user started to resize an object or finalized such an operation.
void removeObjectResizeEventListener (in nsIHTMLObjectResizeListener aListener)
 Deletes a resize listener.
void absolutePositionSelection (in boolean aEnabled)
 extracts the selection from the normal flow of the document and positions it.
void relativeChangeZIndex (in long aChange)
 adds aChange to the z-index of the currently positioned element.
void absolutelyPositionElement (in nsIDOMElement aElement, in boolean aEnabled)
 extracts an element from the normal flow of the document and positions it, and puts it back in the normal flow.
void setElementPosition (in nsIDOMElement aElement, in long aX, in long aY)
 sets the position of an element; warning it does NOT check if the element is already positioned or not and that's on purpose.
long getElementZIndex (in nsIDOMElement aElement)
 returns the absolute z-index of a positioned element.
void setElementZIndex (in nsIDOMElement aElement, in long aZorder)
 sets the z-index of an element.
long relativeChangeElementZIndex (in nsIDOMElement aElement, in long aChange)
 adds aChange to the z-index of an arbitrary element.
void showGrabberOnElement (in nsIDOMElement aElement)
 shows a grabber attached to an arbitrary element.
void hideGrabber ()
 hide the grabber if it shown.
void refreshGrabber ()
 refreshes the grabber if it shown, possibly updating its position or even hiding it.
void insertTableCell (in long aNumber, in boolean aAfter)
 Insert table methods Insert relative to the selected cell or the cell enclosing the selection anchor The selection is collapsed and is left in the new cell at the same row,col location as the original anchor cell.
void insertTableColumn (in long aNumber, in boolean aAfter)
void insertTableRow (in long aNumber, in boolean aAfter)
void deleteTable ()
 Delete table methods Delete starting at the selected cell or the cell (or table) enclosing the selection anchor The selection is collapsed and is left in the cell at the same row,col location as the previous selection anchor, if possible, else in the closest neigboring cell.
void deleteTableCellContents ()
 Delete just the cell contents This is what should happen when Delete key is used for selected cells, to minimize upsetting the table layout.
void deleteTableCell (in long aNumber)
 Delete cell elements as well as contents.
void deleteTableColumn (in long aNumber)
void deleteTableRow (in long aNumber)
void selectTableCell ()
 Table Selection methods Selecting a row or column actually selects all cells (not TR in the case of rows)
void selectBlockOfCells (in nsIDOMElement aStartCell, in nsIDOMElement aEndCell)
 Select a rectangular block of cells: all cells falling within the row/column index of aStartCell to through the row/column index of the aEndCell aStartCell can be any location relative to aEndCell, as long as they are in the same table.
void selectTableRow ()
void selectTableColumn ()
void selectTable ()
void selectAllTableCells ()
nsIDOMElement switchTableCellHeaderType (in nsIDOMElement aSourceCell)
 Create a new TD or TH element, the opposite type of the supplied aSourceCell.
void joinTableCells (in boolean aMergeNonContiguousContents)
 Merges contents of all selected cells for selected cells that are adjacent, this will result in a larger cell with appropriate rowspan and colspan, and original cells are deleted The resulting cell is in the location of the cell at the upper-left corner of the adjacent block of selected cells.
void splitTableCell ()
 Split a cell that has rowspan and/or colspan > 0 into cells such that all new cells have rowspan = 1 and colspan = 1 All of the contents are not touched -- they will appear to be in the upper-left cell.
void normalizeTable (in nsIDOMElement aTable)
 Scan through all rows and add cells as needed so all locations in the cellmap are occupied.
void getCellIndexes (in nsIDOMElement aCell, out long aRowIndex, out long aColIndex)
 Get the row an column index from the layout's cellmap If aCell is null, it will try to find enclosing table of selection anchor.
void getTableSize (in nsIDOMElement aTable, out long aRowCount, out long aColCount)
 Get the number of rows and columns in a table from the layout's cellmap If aTable is null, it will try to find enclosing table of selection ancho Note that all rows in table will not have this many because of ROWSPAN effects or if table is not "rectangular" (has short rows)
nsIDOMElement getCellAt (in nsIDOMElement aTable, in long aRowIndex, in long aColIndex)
 Get a cell element at cellmap grid coordinates A cell that spans across multiple cellmap locations will be returned multiple times, once for each location it occupies.
void getCellDataAt (in nsIDOMElement aTable, in long aRowIndex, in long aColIndex, out nsIDOMElement aCell, out long aStartRowIndex, out long aStartColIndex, out long aRowSpan, out long aColSpan, out long aActualRowSpan, out long aActualColSpan, out boolean aIsSelected)
 Get a cell at cellmap grid coordinates and associated data A cell that spans across multiple cellmap locations will be returned multiple times, once for each location it occupies Examine the returned aStartRowIndex and aStartColIndex to see if it is in the same layout column or layout row: A "layout row" is all cells sharing the same top edge A "layout column" is all cells sharing the same left edge This is important to determine what to do when inserting or deleting a column or row.
nsIDOMNode getFirstRow (in nsIDOMElement aTableElement)
 Get the first row element in a table.
nsIDOMNode getNextRow (in nsIDOMNode aTableElement)
 Get the next row element starting the search from aTableElement.
void setSelectionAfterTableEdit (in nsIDOMElement aTable, in long aRow, in long aCol, in long aDirection, in boolean aSelected)
 Preferred direction to search for neighboring cell when trying to locate a cell to place caret in after a table editing action.
nsIDOMElement getSelectedOrParentTableElement (out AString aTagName, out long aCount)
 Examine the current selection and find a selected TABLE, TD or TH, or TR element.
PRUint32 getSelectedCellsType (in nsIDOMElement aElement)
 Generally used after GetSelectedOrParentTableElement to test if selected cells are complete rows or columns.
nsIDOMElement getFirstSelectedCell (out nsIDOMRange aRange)
 Get first selected element from first selection range.
nsIDOMElement getFirstSelectedCellInTable (out long aRowIndex, out long aColIndex)
 Get first selected element in the table This is the upper-left-most selected cell in table, ignoring the order that the user selected them (order in the selection ranges) Assumes cell-selection model where each cell is in a separate range (selection parent node is table row)
nsIDOMElement getNextSelectedCell (out nsIDOMRange aRange)
 Get next selected cell element from first selection range.
void showInlineTableEditingUI (in nsIDOMElement aCell)
 Shows inline table editing UI around a table cell.
void hideInlineTableEditingUI ()
 Hide all inline table editing UI.
void doInlineTableEditingAction (in nsIDOMElement aUIAnonymousElement)
 Modifies the table containing the selection according to the activation of an inline table editing UI element.
void refreshInlineTableEditingUI ()
 Refresh already visible inline table editing UI.
void replaceStyleSheet (in AString aURL)
 load and apply the style sheet, specified by aURL, to the editor's document, replacing the last style sheet added (if any).
void addStyleSheet (in AString aURL)
 Add the given Style Sheet to the editor's document, on top of any that are already there.
void replaceOverrideStyleSheet (in AString aURL)
 load and apply the style sheet, specified by aURL, to the editor's document, replacing the last style sheet added (if any).
void addOverrideStyleSheet (in AString aURL)
 load and apply an Override style sheet, specified by aURL, to the editor's document, on top of any that are already there.
void removeStyleSheet (in AString aURL)
 Remove the given Style Sheet from the editor's document This is always synchronous.
void removeOverrideStyleSheet (in AString aURL)
 Remove the given Override Style Sheet from the editor's document This is always synchronous.
void enableStyleSheet (in AString aURL, in PRBool aEnable)
 Enable or disable the given Style Sheet from the editor's document This is always synchronous.
nsICSSStyleSheet getStyleSheetForURL (in AString aURL)
 Get the nsICSSStyleSheet associated with the given URL.
AString getURLForStyleSheet (in nsICSSStyleSheet aStyleSheet)
 Get the URL associated with the given nsICSSStyleSheet.

Static Public Member Functions

static nsCOMPtr< nsIDOMNodeGetBlockNodeParent (nsIDOMNode *aNode)
static PRBool HasSameBlockNodeParent (nsIDOMNode *aNode1, nsIDOMNode *aNode2)
static nsresult GetBlockSection (nsIDOMNode *aNode, nsIDOMNode **aLeftNode, nsIDOMNode **aRightNode)
 Determines the bounding nodes for the block section containing aNode.
static nsresult GetBlockSectionsForRange (nsIDOMRange *aRange, nsCOMArray< nsIDOMRange > &aSections)
 Compute the set of block sections in a given range.
static nsCOMPtr< nsIDOMNodeNextNodeInBlock (nsIDOMNode *aNode, IterDirection aDir)
static nsresult NodeIsBlockStatic (nsIDOMNode *aNode, PRBool *aIsBlock)
 Internal, static version.
static void Shutdown ()
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
const short eEditorPlaintextBit = 0
const short eEditorSingleLineBit = 1
const short eEditorPasswordBit = 2
const short eEditorReadonlyBit = 3
const short eEditorDisabledBit = 4
const short eEditorFilterInputBit = 5
const short eEditorMailBit = 6
const short eEditorUseAsyncUpdatesBit = 7
const short eEditorEnableWrapHackBit = 8
const short eEditorWidgetBit = 9
const short eEditorNoCSSBit = 10
const long eEditorPlaintextMask = 1
const long eEditorSingleLineMask = 2
const long eEditorPasswordMask = 4
const long eEditorReadonlyMask = 8
const long eEditorDisabledMask = 16
const long eEditorFilterInputMask = 32
const long eEditorMailMask = 64
const long eEditorUseAsyncUpdatesMask = 128
const long eEditorEnableWrapHackMask = 256
const long eEditorWidgetMask = 512
const long eEditorNoCSSMask = 1024
readonly attribute long textLength
 The length of the contents in characters.
attribute long maxTextLength
 The maximum number of characters allowed.
attribute long wrapWidth
 Get and set the body wrap width.
const short eLeft = 0
const short eCenter = 1
const short eRight = 2
const short eJustify = 3
attribute boolean isCSSEnabled
 A boolean which is true is the HTMLEditor has been instantiated with CSS knowledge and if the CSS pref is currently checked.
attribute boolean returnInParagraphCreatesNewParagraph
 A boolean indicating if a return key pressed in a paragraph creates another paragraph or just inserts a
at the caret.
const short eTopLeft = 0
const short eTop = 1
const short eTopRight = 2
const short eLeft = 3
const short eRight = 4
const short eBottomLeft = 5
const short eBottom = 6
const short eBottomRight = 7
readonly attribute nsIDOMElement resizedObject
 the element currently displaying resizers
attribute boolean objectResizingEnabled
 a boolean indicating if object resizing is enabled in the editor
readonly attribute boolean selectionContainerAbsolutelyPositioned
 true if the selection container is absolutely positioned
readonly attribute nsIDOMElement positionedElement
 this contains the absolutely positioned element currently edited or null
attribute boolean absolutePositioningEnabled
 true if Absolute Positioning handling is enabled in the editor
attribute boolean snapToGridEnabled
 true if Snap To Grid is enabled in the editor.
attribute unsigned long gridSize
 sets the grid size in pixels.
readonly attribute nsIDOMElement absolutelyPositionedSelectionContainer
 returns the deepest absolutely positioned container of the selection if it exists or null.
const short eNoSearch = 0
const short ePreviousColumn = 1
const short ePreviousRow = 2
attribute boolean inlineTableEditingEnabled
 boolean indicating if inline table editing is enabled in the editor.

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 InitRules ()
virtual nsresult CreateEventListeners ()
virtual void RemoveEventListeners ()
NS_IMETHOD GetLayoutObject (nsIDOMNode *aInNode, nsISupports **aOutLayoutObject)
 returns the layout object (nsIFrame in the real world) for aNode
PRBool SetCaretInTableCell (nsIDOMElement *aElement)
PRBool IsElementInBody (nsIDOMElement *aElement)
void ClearInlineStylesCache ()
NS_IMETHOD TabInTable (PRBool inIsShift, PRBool *outHandled)
NS_IMETHOD CreateBR (nsIDOMNode *aNode, PRInt32 aOffset, nsCOMPtr< nsIDOMNode > *outBRNode, nsIEditor::EDirection aSelect=nsIEditor::eNone)
NS_IMETHOD CreateBRImpl (nsCOMPtr< nsIDOMNode > *aInOutParent, PRInt32 *aInOutOffset, nsCOMPtr< nsIDOMNode > *outBRNode, nsIEditor::EDirection aSelect)
NS_IMETHOD InsertBR (nsCOMPtr< nsIDOMNode > *outBRNode)
NS_IMETHOD InsertCell (nsIDOMElement *aCell, PRInt32 aRowSpan, PRInt32 aColSpan, PRBool aAfter, PRBool aIsHeader, nsIDOMElement **aNewCell)
NS_IMETHOD DeleteRow (nsIDOMElement *aTable, PRInt32 aRowIndex)
NS_IMETHOD DeleteColumn (nsIDOMElement *aTable, PRInt32 aColIndex)
NS_IMETHOD DeleteCellContents (nsIDOMElement *aCell)
NS_IMETHOD MergeCells (nsCOMPtr< nsIDOMElement > aTargetCell, nsCOMPtr< nsIDOMElement > aCellToMerge, PRBool aDeleteCellToMerge)
NS_IMETHOD DeleteTable2 (nsIDOMElement *aTable, nsISelection *aSelection)
NS_IMETHOD SetColSpan (nsIDOMElement *aCell, PRInt32 aColSpan)
NS_IMETHOD SetRowSpan (nsIDOMElement *aCell, PRInt32 aRowSpan)
NS_IMETHOD GetTableLayoutObject (nsIDOMElement *aTable, nsITableLayout **tableLayoutObject)
PRInt32 GetNumberOfCellsInRow (nsIDOMElement *aTable, PRInt32 rowIndex)
PRBool AllCellsInRowSelected (nsIDOMElement *aTable, PRInt32 aRowIndex, PRInt32 aNumberOfColumns)
PRBool AllCellsInColumnSelected (nsIDOMElement *aTable, PRInt32 aColIndex, PRInt32 aNumberOfRows)
PRBool IsEmptyCell (nsIDOMElement *aCell)
NS_IMETHOD GetCellContext (nsISelection **aSelection, nsIDOMElement **aTable, nsIDOMElement **aCell, nsIDOMNode **aCellParent, PRInt32 *aCellOffset, PRInt32 *aRowIndex, PRInt32 *aColIndex)
NS_IMETHOD GetCellSpansAt (nsIDOMElement *aTable, PRInt32 aRowIndex, PRInt32 aColIndex, PRInt32 &aActualRowSpan, PRInt32 &aActualColSpan)
NS_IMETHOD SplitCellIntoColumns (nsIDOMElement *aTable, PRInt32 aRowIndex, PRInt32 aColIndex, PRInt32 aColSpanLeft, PRInt32 aColSpanRight, nsIDOMElement **aNewCell)
NS_IMETHOD SplitCellIntoRows (nsIDOMElement *aTable, PRInt32 aRowIndex, PRInt32 aColIndex, PRInt32 aRowSpanAbove, PRInt32 aRowSpanBelow, nsIDOMElement **aNewCell)
nsresult CopyCellBackgroundColor (nsIDOMElement *destCell, nsIDOMElement *sourceCell)
NS_IMETHOD FixBadRowSpan (nsIDOMElement *aTable, PRInt32 aRowIndex, PRInt32 &aNewRowCount)
NS_IMETHOD FixBadColSpan (nsIDOMElement *aTable, PRInt32 aColIndex, PRInt32 &aNewColCount)
NS_IMETHOD SetSelectionAtDocumentStart (nsISelection *aSelection)
NS_IMETHOD IsRootTag (nsString &aTag, PRBool &aIsTag)
NS_IMETHOD IsSubordinateBlock (nsString &aTag, PRBool &aIsTag)
virtual PRBool IsBlockNode (nsIDOMNode *aNode)
virtual void IsTextPropertySetByContent (nsIDOMNode *aNode, nsIAtom *aProperty, const nsAString *aAttribute, const nsAString *aValue, PRBool &aIsSet, nsIDOMNode **aStyleNode, nsAString *outValue=nsnull)
 content-based query returns PR_TRUE if <aProperty aattribute="aValue"> effects aNode If <aProperty aattribute="aValue"> contains aNode, but <aProperty aattribute="SomeOtherValue"> also contains aNode and the second is more deeply nested than the first, then the first does not effect aNode.
void ResetTextSelectionForRange (nsIDOMNode *aParent, PRInt32 aStartOffset, PRInt32 aEndOffset, nsISelection *aSelection)
NS_IMETHOD PasteAsPlaintextQuotation (PRInt32 aSelectionType)
NS_IMETHOD InsertAsPlaintextQuotation (const nsAString &aQuotedText, PRBool aAddCites, nsIDOMNode **aNodeInserted)
 Insert a string as quoted text, replacing the selected text (if any).
NS_IMETHOD PrepareTransferable (nsITransferable **transferable)
NS_IMETHOD PrepareHTMLTransferable (nsITransferable **transferable, PRBool havePrivFlavor)
nsresult PutDragDataInTransferable (nsITransferable **aTransferable)
NS_IMETHOD InsertFromTransferable (nsITransferable *transferable, nsIDOMDocument *aSourceDoc, const nsAString &aContextStr, const nsAString &aInfoStr, nsIDOMNode *aDestinationNode, PRInt32 aDestinationOffset, PRBool aDoDeleteSelection)
PRBool HavePrivateHTMLFlavor (nsIClipboard *clipboard)
nsresult ParseCFHTML (nsCString &aCfhtml, PRUnichar **aStuffToPaste, PRUnichar **aCfcontext)
nsresult DoContentFilterCallback (const nsAString &aFlavor, nsIDOMDocument *aSourceDoc, PRBool aWillDeleteSelection, nsIDOMNode **aFragmentAsNode, nsIDOMNode **aFragStartNode, PRInt32 *aFragStartOffset, nsIDOMNode **aFragEndNode, PRInt32 *aFragEndOffset, nsIDOMNode **aTargetNode, PRInt32 *aTargetOffset, PRBool *aDoContinue)
nsresult RelativizeURIInFragmentList (nsCOMArray< nsIDOMNode > aNodeList, const nsAString &aFlavor, nsIDOMDocument *aSourceDoc, nsIDOMNode *aTargetNode)
nsresult RelativizeURIForNode (nsIDOMNode *aNode, nsIURL *aDestURL)
nsresult GetAttributeToModifyOnNode (nsIDOMNode *aNode, nsAString &aAttrib)
PRBool IsInLink (nsIDOMNode *aNode, nsCOMPtr< nsIDOMNode > *outLink=nsnull)
nsresult StripFormattingNodes (nsIDOMNode *aNode, PRBool aOnlyList=PR_FALSE)
nsresult CreateDOMFragmentFromPaste (const nsAString &aInputString, const nsAString &aContextStr, const nsAString &aInfoStr, nsCOMPtr< nsIDOMNode > *outFragNode, PRInt32 *outRangeStartHint, PRInt32 *outRangeEndHint)
nsresult ParseFragment (const nsAString &aStr, nsVoidArray &aTagStack, nsIDocument *aTargetDoc, nsCOMPtr< nsIDOMNode > *outNode)
nsresult CreateListOfNodesToPaste (nsIDOMNode *aFragmentAsNode, nsCOMArray< nsIDOMNode > &outNodeList, nsIDOMNode *aStartNode, PRInt32 aStartOffset, nsIDOMNode *aEndNode, PRInt32 aEndOffset)
nsresult CreateTagStack (nsVoidArray &aTagStack, nsIDOMNode *aNode)
void FreeTagStackStrings (nsVoidArray &tagStack)
nsresult GetListAndTableParents (PRBool aEnd, nsCOMArray< nsIDOMNode > &aListOfNodes, nsCOMArray< nsIDOMNode > &outArray)
nsresult DiscoverPartialListsAndTables (nsCOMArray< nsIDOMNode > &aPasteNodes, nsCOMArray< nsIDOMNode > &aListsAndTables, PRInt32 *outHighWaterMark)
nsresult ScanForListAndTableStructure (PRBool aEnd, nsCOMArray< nsIDOMNode > &aNodes, nsIDOMNode *aListOrTable, nsCOMPtr< nsIDOMNode > *outReplaceNode)
nsresult ReplaceOrphanedStructure (PRBool aEnd, nsCOMArray< nsIDOMNode > &aNodeArray, nsCOMArray< nsIDOMNode > &aListAndTableArray, PRInt32 aHighWaterMark)
nsIDOMNodeGetArrayEndpoint (PRBool aEnd, nsCOMArray< nsIDOMNode > &aNodeArray)
PRBool IsVisBreak (nsIDOMNode *aNode)
void NormalizeEOLInsertPosition (nsIDOMNode *firstNodeToInsert, nsCOMPtr< nsIDOMNode > *insertParentNode, PRInt32 *insertOffset)
PRBool IsModifiable ()
nsresult MakeDefinitionItem (const nsAString &aItemType)
nsresult InsertBasicBlock (const nsAString &aBlockType)
nsresult RelativeFontChange (PRInt32 aSizeChange)
nsresult RelativeFontChangeOnTextNode (PRInt32 aSizeChange, nsIDOMCharacterData *aTextNode, PRInt32 aStartOffset, PRInt32 aEndOffset)
nsresult RelativeFontChangeOnNode (PRInt32 aSizeChange, nsIDOMNode *aNode)
nsresult RelativeFontChangeHelper (PRInt32 aSizeChange, nsIDOMNode *aNode)
nsresult SetInlinePropertyOnTextNode (nsIDOMCharacterData *aTextNode, PRInt32 aStartOffset, PRInt32 aEndOffset, nsIAtom *aProperty, const nsAString *aAttribute, const nsAString *aValue)
nsresult SetInlinePropertyOnNode (nsIDOMNode *aNode, nsIAtom *aProperty, const nsAString *aAttribute, const nsAString *aValue)
nsresult PromoteInlineRange (nsIDOMRange *inRange)
nsresult PromoteRangeIfStartsOrEndsInNamedAnchor (nsIDOMRange *inRange)
nsresult SplitStyleAboveRange (nsIDOMRange *aRange, nsIAtom *aProperty, const nsAString *aAttribute)
nsresult SplitStyleAbovePoint (nsCOMPtr< nsIDOMNode > *aNode, PRInt32 *aOffset, nsIAtom *aProperty, const nsAString *aAttribute, nsCOMPtr< nsIDOMNode > *outLeftNode=nsnull, nsCOMPtr< nsIDOMNode > *outRightNode=nsnull)
nsresult ApplyDefaultProperties ()
nsresult RemoveStyleInside (nsIDOMNode *aNode, nsIAtom *aProperty, const nsAString *aAttribute, PRBool aChildrenOnly=PR_FALSE)
nsresult RemoveInlinePropertyImpl (nsIAtom *aProperty, const nsAString *aAttribute)
PRBool NodeIsProperty (nsIDOMNode *aNode)
PRBool HasAttr (nsIDOMNode *aNode, const nsAString *aAttribute)
PRBool HasAttrVal (nsIDOMNode *aNode, const nsAString *aAttribute, const nsAString *aValue)
PRBool IsAtFrontOfNode (nsIDOMNode *aNode, PRInt32 aOffset)
PRBool IsAtEndOfNode (nsIDOMNode *aNode, PRInt32 aOffset)
PRBool IsOnlyAttribute (nsIDOMNode *aElement, const nsAString *aAttribute)
nsresult RemoveBlockContainer (nsIDOMNode *inNode)
nsresult GetPriorHTMLSibling (nsIDOMNode *inNode, nsCOMPtr< nsIDOMNode > *outNode)
nsresult GetPriorHTMLSibling (nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr< nsIDOMNode > *outNode)
nsresult GetNextHTMLSibling (nsIDOMNode *inNode, nsCOMPtr< nsIDOMNode > *outNode)
nsresult GetNextHTMLSibling (nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr< nsIDOMNode > *outNode)
nsresult GetPriorHTMLNode (nsIDOMNode *inNode, nsCOMPtr< nsIDOMNode > *outNode, PRBool bNoBlockCrossing=PR_FALSE)
nsresult GetPriorHTMLNode (nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr< nsIDOMNode > *outNode, PRBool bNoBlockCrossing=PR_FALSE)
nsresult GetNextHTMLNode (nsIDOMNode *inNode, nsCOMPtr< nsIDOMNode > *outNode, PRBool bNoBlockCrossing=PR_FALSE)
nsresult GetNextHTMLNode (nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr< nsIDOMNode > *outNode, PRBool bNoBlockCrossing=PR_FALSE)
nsresult IsFirstEditableChild (nsIDOMNode *aNode, PRBool *aOutIsFirst)
nsresult IsLastEditableChild (nsIDOMNode *aNode, PRBool *aOutIsLast)
nsresult GetFirstEditableChild (nsIDOMNode *aNode, nsCOMPtr< nsIDOMNode > *aOutFirstChild)
nsresult GetLastEditableChild (nsIDOMNode *aNode, nsCOMPtr< nsIDOMNode > *aOutLastChild)
nsresult GetFirstEditableLeaf (nsIDOMNode *aNode, nsCOMPtr< nsIDOMNode > *aOutFirstLeaf)
nsresult GetLastEditableLeaf (nsIDOMNode *aNode, nsCOMPtr< nsIDOMNode > *aOutLastLeaf)
nsresult GetInlinePropertyBase (nsIAtom *aProperty, const nsAString *aAttribute, const nsAString *aValue, PRBool *aFirst, PRBool *aAny, PRBool *aAll, nsAString *outValue, PRBool aCheckDefaults=PR_TRUE)
nsresult HasStyleOrIdOrClass (nsIDOMElement *aElement, PRBool *aHasStyleOrIdOrClass)
nsresult RemoveElementIfNoStyleOrIdOrClass (nsIDOMElement *aElement, nsIAtom *aTag)
void RemoveListenerAndDeleteRef (const nsAString &aEvent, nsIDOMEventListener *aListener, PRBool aUseCapture, nsIDOMElement *aElement, nsIContent *aParentContent, nsIPresShell *aShell)
void DeleteRefToAnonymousNode (nsIDOMElement *aElement, nsIContent *aParentContent, nsIPresShell *aShell)
nsresult GetElementOrigin (nsIDOMElement *aElement, PRInt32 &aX, PRInt32 &aY)
nsresult GetPositionAndDimensions (nsIDOMElement *aElement, PRInt32 &aX, PRInt32 &aY, PRInt32 &aW, PRInt32 &aH, PRInt32 &aBorderLeft, PRInt32 &aBorderTop, PRInt32 &aMarginLeft, PRInt32 &aMarginTop)
nsresult SetAllResizersPosition ()
nsresult CreateResizer (nsIDOMElement **aReturn, PRInt16 aLocation, nsIDOMNode *aParentNode)
void SetAnonymousElementPosition (PRInt32 aX, PRInt32 aY, nsIDOMElement *aResizer)
nsresult CreateShadow (nsIDOMElement **aReturn, nsIDOMNode *aParentNode, nsIDOMElement *aOriginalObject)
nsresult SetShadowPosition (nsIDOMElement *aShadow, nsIDOMElement *aOriginalObject, PRInt32 aOriginalObjectX, PRInt32 aOriginalObjectY)
nsresult CreateResizingInfo (nsIDOMElement **aReturn, nsIDOMNode *aParentNode)
nsresult SetResizingInfoPosition (PRInt32 aX, PRInt32 aY, PRInt32 aW, PRInt32 aH)
PRInt32 GetNewResizingIncrement (PRInt32 aX, PRInt32 aY, PRInt32 aID)
nsresult StartResizing (nsIDOMElement *aHandle)
PRInt32 GetNewResizingX (PRInt32 aX, PRInt32 aY)
PRInt32 GetNewResizingY (PRInt32 aX, PRInt32 aY)
PRInt32 GetNewResizingWidth (PRInt32 aX, PRInt32 aY)
PRInt32 GetNewResizingHeight (PRInt32 aX, PRInt32 aY)
void HideShadowAndInfo ()
void SetFinalSize (PRInt32 aX, PRInt32 aY)
void DeleteRefToAnonymousNode (nsIDOMNode *aNode)
void SetResizeIncrements (PRInt32 aX, PRInt32 aY, PRInt32 aW, PRInt32 aH, PRBool aPreserveRatio)
void SetInfoIncrements (PRInt8 aX, PRInt8 aY)
nsresult CreateGrabber (nsIDOMNode *aParentNode, nsIDOMElement **aReturn)
nsresult StartMoving (nsIDOMElement *aHandle)
nsresult SetFinalPosition (PRInt32 aX, PRInt32 aY)
void AddPositioningOffet (PRInt32 &aX, PRInt32 &aY)
void SnapToGrid (PRInt32 &newX, PRInt32 &newY)
nsresult GrabberClicked ()
nsresult EndMoving ()
nsresult CheckPositionedElementBGandFG (nsIDOMElement *aElement, nsAString &aReturn)
void AddMouseClickListener (nsIDOMElement *aElement)
void RemoveMouseClickListener (nsIDOMElement *aElement)
void BeginEditorInit ()
nsresult EndEditorInit ()
NS_IMETHOD GetAndInitDocEncoder (const nsAString &aFormatType, PRUint32 aFlags, const nsACString &aCharset, nsIDocumentEncoder **encoder)
NS_IMETHOD InsertTextFromTransferable (nsITransferable *transferable, nsIDOMNode *aDestinationNode, PRInt32 aDestOffset, PRBool aDoDeleteSelection)
virtual nsresult SetupDocEncoder (nsIDocumentEncoder **aDocEncoder)
nsresult SharedOutputString (PRUint32 aFlags, PRBool *aIsCollapsed, nsAString &aResult)
 shared outputstring; returns whether selection is collapsed and resulting string
NS_IMETHOD IgnoreSpuriousDragEvent (PRBool aIgnoreSpuriousDragEvent)
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 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 GetWrapWidth (PRInt32 *aWrapCol)
NS_IMETHOD ScrollSelectionIntoView (PRBool aScrollToAnchor)
 helper method for scrolling the selection into view after an edit operation.
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 ()
PRBool GetDesiredSpellCheckState ()
 Return true if spellchecking should be enabled for this editor.

Static Protected Member Functions

static nsCOMPtr< nsIDOMNodeGetEnclosingTable (nsIDOMNode *aNode)

Protected Attributes

PRBool mIgnoreSpuriousDragEvent
nsCOMArray< nsIContentFiltermContentFilters
TypeInStatemTypeInState
nsCOMPtr< nsIDOMNodemCachedNode
PRPackedBool mCRInParagraphCreatesParagraph
PRPackedBool mCSSAware
nsHTMLCSSUtilsmHTMLCSSUtils
PRInt32 mSelectedCellIndex
nsString mLastStyleSheetURL
nsString mLastOverrideStyleSheetURL
nsStringArray mStyleSheetURLs
nsCOMArray< nsICSSStyleSheetmStyleSheets
nsVoidArray mDefaultStyles
nsCOMPtr< nsITextServicesDocumentmTextServices
PRPackedBool mIsObjectResizingEnabled
PRPackedBool mIsResizing
PRPackedBool mPreserveRatio
PRPackedBool mResizedObjectIsAnImage
PRPackedBool mIsAbsolutelyPositioningEnabled
PRPackedBool mResizedObjectIsAbsolutelyPositioned
PRPackedBool mGrabberClicked
PRPackedBool mIsMoving
PRPackedBool mSnapToGridEnabled
PRPackedBool mIsInlineTableEditingEnabled
nsCOMPtr< nsIDOMElementmTopLeftHandle
nsCOMPtr< nsIDOMElementmTopHandle
nsCOMPtr< nsIDOMElementmTopRightHandle
nsCOMPtr< nsIDOMElementmLeftHandle
nsCOMPtr< nsIDOMElementmRightHandle
nsCOMPtr< nsIDOMElementmBottomLeftHandle
nsCOMPtr< nsIDOMElementmBottomHandle
nsCOMPtr< nsIDOMElementmBottomRightHandle
nsCOMPtr< nsIDOMElementmActivatedHandle
nsCOMPtr< nsIDOMElementmResizingShadow
nsCOMPtr< nsIDOMElementmResizingInfo
nsCOMPtr< nsIDOMElementmResizedObject
nsCOMPtr< nsIDOMEventListenermMouseMotionListenerP
nsCOMPtr< nsISelectionListenermSelectionListenerP
nsCOMPtr< nsIDOMEventListenermResizeEventListenerP
nsCOMArray
< nsIHTMLObjectResizeListener
objectResizeEventListeners
PRInt32 mOriginalX
PRInt32 mOriginalY
PRInt32 mResizedObjectX
PRInt32 mResizedObjectY
PRInt32 mResizedObjectWidth
PRInt32 mResizedObjectHeight
PRInt32 mResizedObjectMarginLeft
PRInt32 mResizedObjectMarginTop
PRInt32 mResizedObjectBorderLeft
PRInt32 mResizedObjectBorderTop
PRInt32 mXIncrementFactor
PRInt32 mYIncrementFactor
PRInt32 mWidthIncrementFactor
PRInt32 mHeightIncrementFactor
PRInt8 mInfoXIncrement
PRInt8 mInfoYIncrement
PRInt32 mPositionedObjectX
PRInt32 mPositionedObjectY
PRInt32 mPositionedObjectWidth
PRInt32 mPositionedObjectHeight
PRInt32 mPositionedObjectMarginLeft
PRInt32 mPositionedObjectMarginTop
PRInt32 mPositionedObjectBorderLeft
PRInt32 mPositionedObjectBorderTop
nsCOMPtr< nsIDOMElementmAbsolutelyPositionedObject
nsCOMPtr< nsIDOMElementmGrabber
nsCOMPtr< nsIDOMElementmPositioningShadow
PRInt32 mGridSize
nsCOMPtr< nsIDOMElementmInlineEditedCell
nsCOMPtr< nsIDOMElementmAddColumnBeforeButton
nsCOMPtr< nsIDOMElementmRemoveColumnButton
nsCOMPtr< nsIDOMElementmAddColumnAfterButton
nsCOMPtr< nsIDOMElementmAddRowBeforeButton
nsCOMPtr< nsIDOMElementmRemoveRowButton
nsCOMPtr< nsIDOMElementmAddRowAfterButton
nsCOMPtr< nsILinkHandlermLinkHandler
nsCOMPtr< nsIEditRulesmRules
PRBool mWrapToWindow
PRInt32 mWrapColumn
PRInt32 mMaxTextLength
PRInt32 mInitTriggerCounter
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

Static Protected Attributes

static nsIRangeUtilssRangeHelper

Private Types

enum  BlockTransformationType { eNoOp, eReplaceParent = 1, eInsertParent = 2 }

Friends

class nsHTMLEditRules
class nsTextEditRules
class nsWSRunObject
class nsAutoEditInitRulesTrigger
class nsAutoTxnsConserveSelection
class nsAutoSelectionReset
class nsAutoRules
class nsRangeUpdater
PRBool NSCanUnload (nsISupports *serviceMgr)

Detailed Description

The HTML editor implementation.


Use to edit HTML document represented as a DOM tree.

Definition at line 92 of file nsHTMLEditor.h.


Member Typedef Documentation

typedef short nsIHTMLEditor::EAlignment [inherited]

Definition at line 59 of file nsIHTMLEditor.idl.

typedef short nsIEditor::EDirection [inherited]

Definition at line 71 of file nsIEditor.idl.

typedef short nsIHTMLObjectResizer::EResizerLocation [inherited]

Definition at line 49 of file nsIHTMLObjectResizer.idl.


Member Enumeration Documentation

anonymous enum [inherited]
Enumerator:
eTypedText 
eTypedBR 
eTypedBreak 

Definition at line 74 of file nsPlaintextEditor.h.

       {
    eTypedText,  /* user typed text */
    eTypedBR,    /* user typed shift-enter to get a br */
    eTypedBreak  /* user typed enter */
  };
Enumerator:
eNoOp 
eReplaceParent 
eInsertParent 

Definition at line 101 of file nsHTMLEditor.h.

enum nsEditor::IterDirection [inherited]
Enumerator:
kIterForward 
kIterBackward 

Definition at line 105 of file nsEditor.h.

Enumerator:
kOpInsertBreak 
kOpMakeList 
kOpIndent 
kOpOutdent 
kOpAlign 
kOpMakeBasicBlock 
kOpRemoveList 
kOpMakeDefListItem 
kOpInsertElement 
kOpInsertQuotation 
kOpSetTextProperty 
kOpRemoveTextProperty 
kOpHTMLPaste 
kOpLoadHTML 
kOpResetTextProperties 
kOpSetAbsolutePosition 
kOpRemoveAbsolutePosition 
kOpDecreaseZIndex 
kOpIncreaseZIndex 

Reimplemented from nsEditor.

Definition at line 105 of file nsHTMLEditor.h.

Enumerator:
kX 
kY 
kWidth 
kHeight 

Definition at line 128 of file nsHTMLEditor.h.

  {
    kX      = 0,
    kY      = 1,
    kWidth  = 2,
    kHeight = 3
  };
enum nsEditor::TDocumentListenerNotification [protected, inherited]
Enumerator:
eDocumentCreated 
eDocumentToBeDestroyed 
eDocumentStateChanged 

Definition at line 292 of file nsEditor.h.

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

Definition at line 601 of file nsEditor.h.


Constructor & Destructor Documentation

Definition at line 173 of file nsHTMLEditor.cpp.

{
  // remove the rules as an action listener.  Else we get a bad
  // ownership loop later on.  it's ok if the rules aren't a listener;
  // we ignore the error.
  nsCOMPtr<nsIEditActionListener> mListener = do_QueryInterface(mRules);
  RemoveEditActionListener(mListener);
  
  // Clean up after our anonymous content -- we don't want these nodes to
  // stay around (which they would, since the frames have an owning reference).

  if (mAbsolutelyPositionedObject)
    HideGrabber();
  if (mInlineEditedCell)
    HideInlineTableEditingUI();
  if (mResizedObject)
    HideResizers();

  //the autopointers will clear themselves up. 
  //but we need to also remove the listeners or we have a leak
  nsCOMPtr<nsISelection>selection;
  nsresult result = GetSelection(getter_AddRefs(selection));
  // if we don't get the selection, just skip this
  if (NS_SUCCEEDED(result) && selection) 
  {
    nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
    nsCOMPtr<nsISelectionListener>listener;
    listener = do_QueryInterface(mTypeInState);
    if (listener)
    {
      selPriv->RemoveSelectionListener(listener); 
    }
    listener = do_QueryInterface(mSelectionListenerP);
    if (listener)
    {
      selPriv->RemoveSelectionListener(listener); 
    }
  }

  NS_IF_RELEASE(mTypeInState);
  mSelectionListenerP = nsnull;

  delete mHTMLCSSUtils;

  // free any default style propItems
  RemoveAllDefaultProperties();

  while (mStyleSheetURLs.Count())
  {
    nsAString* strp = mStyleSheetURLs.StringAt(0);

    if (strp)
    {
      RemoveOverrideStyleSheet(*strp);
    }
  }

  if (mLinkHandler && mPresShellWeak)
  {
    nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);

    if (ps && ps->GetPresContext())
    {
      ps->GetPresContext()->SetLinkHandler(mLinkHandler);
    }
  }

  RemoveEventListeners();
}

Here is the call graph for this function:


Member Function Documentation

extracts an element from the normal flow of the document and positions it, and puts it back in the normal flow.

Parameters:
aElement[IN] the element
aEnabled[IN] true to absolutely position the element, false to put it back in the normal flow

extracts the selection from the normal flow of the document and positions it.

Parameters:
aEnabled[IN] true to absolutely position the selection, false to put it back in the normal flow
void nsIHTMLEditor::addDefaultProperty ( in nsIAtom  aProperty,
in AString  aAttribute,
in AString  aValue 
) [inherited]

AddDefaultProperty() registers a default style property with the editor.

Parameters:
aPropertythe property to set by default
aAttributethe attribute of the property, if applicable. May be null. Example: aProperty="font", aAttribute="color"
aValueif aAttribute is not null, the value of the attribute. Example: aProperty="font", aAttribute="color", aValue="0x00FFFF"

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.

Add listener for insertion override.

Parameters:
inFilterfunction which callers want called during insertion

Definition at line 206 of file nsHTMLInlineTableEditor.cpp.

{
  nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(aElement));
  if (evtTarget)
    evtTarget->AddEventListener(NS_LITERAL_STRING("click"), mMouseListenerP, PR_TRUE);
}

Here is the call graph for this function:

nsresult nsHTMLEditor::AddNewStyleSheetToList ( const nsAString &  aURL,
nsICSSStyleSheet aStyleSheet 
)

Definition at line 3715 of file nsHTMLEditor.cpp.

{
  PRInt32 countSS = mStyleSheets.Count();
  PRInt32 countU = mStyleSheetURLs.Count();

  if (countU < 0 || countSS != countU)
    return NS_ERROR_UNEXPECTED;

  if (!mStyleSheetURLs.AppendString(aURL))
    return NS_ERROR_UNEXPECTED;

  return mStyleSheets.AppendObject(aStyleSheet) ? NS_OK : NS_ERROR_UNEXPECTED;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Creates a resize listener that can be used to get notifications that the user started to resize an object or finalized such an operation.

Parameters:
aListener[IN] an instance of nsIHTMLObjectResizeListener
void nsIEditorStyleSheets::addOverrideStyleSheet ( in AString  aURL) [inherited]

load and apply an Override style sheet, specified by aURL, to the editor's document, on top of any that are already there.

IMPORTANT: This is assumed to be synchronous: URL is a local file with no used This action is not undoable. It is not intended for use by "user", only editor developers to change display behavior for editing (like showing special cursors) that will not be affected by loading other "document" style sheets loaded using addStyleSheet or replaceStyleSheet.

Parameters:
aURLThe style sheet to be loaded and applied.

Definition at line 3593 of file nsHTMLEditor.cpp.

{
  // Enable existing sheet if already loaded.
  if (EnableExistingStyleSheet(aURL))
    return NS_OK;

  nsCOMPtr<nsICSSLoader> cssLoader;
  nsresult rv = GetCSSLoader(aURL, getter_AddRefs(cssLoader));
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIURI> uaURI;
  rv = NS_NewURI(getter_AddRefs(uaURI), aURL);
  NS_ENSURE_SUCCESS(rv, rv);

  // We MUST ONLY load synchronous local files (no @import)
  nsCOMPtr<nsICSSStyleSheet> sheet;
  nsCOMPtr<nsICSSLoader_MOZILLA_1_8_BRANCH> loader = do_QueryInterface(cssLoader);
  rv = loader->LoadSheetSync(uaURI, PR_TRUE, getter_AddRefs(sheet));

  // Synchronous loads should ALWAYS return completed
  if (!sheet)
    return NS_ERROR_NULL_POINTER;

  nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
  if (!ps)
    return NS_ERROR_NOT_INITIALIZED;

  // Add the override style sheet
  // (This checks if already exists)
  ps->AddOverrideStyleSheet(sheet);

  // Save doc pointer to be able to use nsIStyleSheet::SetEnabled()
  nsIDocument *document = ps->GetDocument();
  if (!document)
    return NS_ERROR_NULL_POINTER;
  sheet->SetOwningDocument(document);

  ps->ReconstructStyleData();

  // Save as the last-loaded sheet
  mLastOverrideStyleSheetURL = aURL;

  //Add URL and style sheet to our lists
  return AddNewStyleSheetToList(aURL, sheet);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsHTMLEditor::AddPositioningOffet ( PRInt32 aX,
PRInt32 aY 
) [protected]

Definition at line 487 of file nsHTMLAbsPosition.cpp.

{
  // Get the positioning offset
  nsresult res;
  nsCOMPtr<nsIPrefBranch> prefBranch =
    do_GetService(NS_PREFSERVICE_CONTRACTID, &res);
  PRInt32 positioningOffset = 0;
  if (NS_SUCCEEDED(res) && prefBranch) {
    res = prefBranch->GetIntPref("editor.positioning.offset", &positioningOffset);
    if (NS_FAILED(res)) // paranoia
      positioningOffset = 0;
  }

  aX += positioningOffset;
  aY += positioningOffset;
}

Here is the call graph for this function:

void nsIEditorStyleSheets::addStyleSheet ( in AString  aURL) [inherited]

Add the given Style Sheet to the editor's document, on top of any that are already there.

This is always synchronous.

Parameters:
aURLThe style sheet to be applied.

Definition at line 3518 of file nsHTMLEditor.cpp.

{
  // Enable existing sheet if already loaded.
  if (EnableExistingStyleSheet(aURL))
    return NS_OK;

  // Lose the previously-loaded sheet so there's nothing to replace
  // This pattern is different from Override methods because
  //  we must wait to remove mLastStyleSheetURL and add new sheet
  //  at the same time (in StyleSheetLoaded callback) so they are undoable together
  mLastStyleSheetURL.Truncate();
  return ReplaceStyleSheet(aURL);
}

Here is the call graph for this function:

void nsIHTMLEditor::align ( in AString  aAlign) [inherited]

Document me!

PRBool nsHTMLEditor::AllCellsInColumnSelected ( nsIDOMElement aTable,
PRInt32  aColIndex,
PRInt32  aNumberOfRows 
) [protected]

Definition at line 3499 of file nsTableEditor.cpp.

{
  if (!aTable) return PR_FALSE;

  PRInt32 curStartRowIndex, curStartColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
  PRBool  isSelected;

  for( PRInt32 row = 0; row < aNumberOfRows; row += PR_MAX(actualRowSpan, 1))
  {
    nsCOMPtr<nsIDOMElement> cell;    
    nsresult res = GetCellDataAt(aTable, row, aColIndex, getter_AddRefs(cell),
                                 &curStartRowIndex, &curStartColIndex,
                                 &rowSpan, &colSpan,
                                 &actualRowSpan, &actualColSpan, &isSelected);
    
    if (NS_FAILED(res)) return PR_FALSE;
    // If no cell, we must have a "ragged" right edge on the last column
    //   so return TRUE only if we already found a cell in the row
    if (!cell) return (row > 0) ? PR_TRUE : PR_FALSE;

    // Return as soon as a non-selected cell is found
    if (!isSelected)
      return PR_FALSE;
  }
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsHTMLEditor::AllCellsInRowSelected ( nsIDOMElement aTable,
PRInt32  aRowIndex,
PRInt32  aNumberOfColumns 
) [protected]

Definition at line 3469 of file nsTableEditor.cpp.

{
  if (!aTable) return PR_FALSE;

  PRInt32 curStartRowIndex, curStartColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
  PRBool  isSelected;

  for( PRInt32 col = 0; col < aNumberOfColumns; col += PR_MAX(actualColSpan, 1))
  {
    nsCOMPtr<nsIDOMElement> cell;    
    nsresult res = GetCellDataAt(aTable, aRowIndex, col, getter_AddRefs(cell),
                                 &curStartRowIndex, &curStartColIndex,
                                 &rowSpan, &colSpan,
                                 &actualRowSpan, &actualColSpan, &isSelected);
 
    if (NS_FAILED(res)) return PR_FALSE;
    // If no cell, we may have a "ragged" right edge,
    //   so return TRUE only if we already found a cell in the row
    if (!cell) return (col > 0) ? PR_TRUE : PR_FALSE;

    // Return as soon as a non-selected cell is found
    if (!isSelected)
      return PR_FALSE;

    NS_ASSERTION((actualColSpan > 0),"ActualColSpan = 0 in AllCellsInRowSelected");
  }
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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:

Definition at line 636 of file nsHTMLEditorStyle.cpp.

{
  nsresult res = NS_OK;
  PRInt32 j, defcon = mDefaultStyles.Count();
  for (j=0; j<defcon; j++)
  {
    PropItem *propItem = (PropItem*)mDefaultStyles[j];
    if (!propItem) 
      return NS_ERROR_NULL_POINTER;
    res = SetInlineProperty(propItem->tag, propItem->attr, propItem->value);
    if (NS_FAILED(res)) return res;
  }
  return res;
}

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.

Definition at line 826 of file nsPlaintextEditor.cpp.

Here is the call graph for this function:

void nsPlaintextEditor::BeginEditorInit ( ) [protected, inherited]

Definition at line 144 of file nsPlaintextEditor.cpp.

Here is the caller graph for this function:

Reimplemented in nsHTMLEditorLog.

Definition at line 447 of file nsHTMLEditor.cpp.

{
  if (!mDocWeak || !mPresShellWeak) { return NS_ERROR_NOT_INITIALIZED; }

  // get the selection
  nsCOMPtr<nsISelection> selection;
  nsresult res = GetSelection(getter_AddRefs(selection));
  if (NS_FAILED(res))
    return res;
  if (!selection)
    return NS_ERROR_NOT_INITIALIZED;
    
  // get the root element 
  nsIDOMElement *rootElement = GetRoot(); 
  if (!rootElement)   return NS_ERROR_NULL_POINTER; 
  
  // find first editable thingy
  PRBool done = PR_FALSE;
  nsCOMPtr<nsIDOMNode> curNode(rootElement), selNode;
  PRInt32 curOffset = 0, selOffset;
  while (!done)
  {
    nsWSRunObject wsObj(this, curNode, curOffset);
    nsCOMPtr<nsIDOMNode> visNode;
    PRInt32 visOffset=0;
    PRInt16 visType=0;
    wsObj.NextVisibleNode(curNode, curOffset, address_of(visNode), &visOffset, &visType);
    if ((visType==nsWSRunObject::eNormalWS) || 
        (visType==nsWSRunObject::eText))
    {
      selNode = visNode;
      selOffset = visOffset;
      done = PR_TRUE;
    }
    else if ((visType==nsWSRunObject::eBreak)    ||
             (visType==nsWSRunObject::eSpecial))
    {
      res = GetNodeLocation(visNode, address_of(selNode), &selOffset);
      if (NS_FAILED(res)) return res; 
      done = PR_TRUE;
    }
    else if (visType==nsWSRunObject::eOtherBlock)
    {
      // By definition of nsWSRunObject, a block element terminates 
      // a whitespace run. That is, although we are calling a method 
      // that is named "NextVisibleNode", the node returned
      // might not be visible/editable!
      // If the given block does not contain any visible/editable items,
      // we want to skip it and continue our search.

      if (!IsContainer(visNode))
      {
        // However, we were given a block that is not a container.
        // Since the block can not contain anything that's visible,
        // such a block only makes sense if it is visible by itself,
        // like a <hr>
        // We want to place the caret in front of that block.

        res = GetNodeLocation(visNode, address_of(selNode), &selOffset);
        if (NS_FAILED(res)) return res; 
        done = PR_TRUE;
      }
      else
      {
        PRBool isEmptyBlock;
        if (NS_SUCCEEDED(IsEmptyNode(visNode, &isEmptyBlock)) &&
            isEmptyBlock)
        {
          // skip the empty block
          res = GetNodeLocation(visNode, address_of(curNode), &curOffset);
          if (NS_FAILED(res)) return res; 
          ++curOffset;
        }
        else
        {
          curNode = visNode;
          curOffset = 0;
        }
        // keep looping
      }
    }
    else
    {
      // else we found nothing useful
      selNode = curNode;
      selOffset = curOffset;
      done = PR_TRUE;
    }
  }
  return selection->Collapse(selNode, selOffset);
}

Here is the call graph for this function:

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 
) [inherited]

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:

NS_IMETHODIMP nsPlaintextEditor::CanCopy ( PRBool aCanCopy) [inherited]

Definition at line 1107 of file nsPlaintextEditor.cpp.

{
  if (!aCanCopy)
    return NS_ERROR_NULL_POINTER;
  *aCanCopy = PR_FALSE;
  
  nsCOMPtr<nsISelection> selection;
  nsresult res = GetSelection(getter_AddRefs(selection));
  if (NS_FAILED(res)) return res;
    
  PRBool isCollapsed;
  res = selection->GetIsCollapsed(&isCollapsed);
  if (NS_FAILED(res)) return res;

  *aCanCopy = !isCollapsed;
  return NS_OK;
}

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.

NS_IMETHODIMP nsPlaintextEditor::CanCut ( PRBool aCanCut) [inherited]

Definition at line 1090 of file nsPlaintextEditor.cpp.

{
  nsresult res = CanCopy(aCanCut);
  if (NS_FAILED(res)) return res;
    
  *aCanCut = *aCanCut && IsModifiable();
  return NS_OK;
}

Here is the call graph for this function:

boolean nsIEditor::canCut ( ) [inherited]

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

NS_IMETHODIMP nsPlaintextEditor::CanDrag ( nsIDOMEvent aDragEvent,
PRBool aCanDrag 
) [inherited]

Definition at line 308 of file nsPlaintextDataTransfer.cpp.

{
  if (!aCanDrag)
    return NS_ERROR_NULL_POINTER;
  /* we really should be checking the XY coordinates of the mouseevent and ensure that
   * that particular point is actually within the selection (not just that there is a selection)
   */
  *aCanDrag = PR_FALSE;
 
  // KLUDGE to work around bug 50703
  // After double click and object property editing, 
  //  we get a spurious drag event
  if (mIgnoreSpuriousDragEvent)
  {
    mIgnoreSpuriousDragEvent = PR_FALSE;
    return NS_OK;
  }
   
  nsCOMPtr<nsISelection> selection;
  nsresult res = GetSelection(getter_AddRefs(selection));
  if (NS_FAILED(res)) return res;
    
  PRBool isCollapsed;
  res = selection->GetIsCollapsed(&isCollapsed);
  if (NS_FAILED(res)) return res;
  
  // if we are collapsed, we have no selection so nothing to drag
  if ( isCollapsed )
    return NS_OK;

  nsCOMPtr<nsIDOMEventTarget> eventTarget;

  nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aDragEvent));
  if (nsevent) {
    res = nsevent->GetTmpRealOriginalTarget(getter_AddRefs(eventTarget));
    if (NS_FAILED(res)) return res;
  }

  if (eventTarget)
  {
    nsCOMPtr<nsIDOMNode> eventTargetDomNode = do_QueryInterface(eventTarget);
    if ( eventTargetDomNode )
    {
      PRBool isTargetedCorrectly = PR_FALSE;
      res = selection->ContainsNode(eventTargetDomNode, PR_FALSE, &isTargetedCorrectly);
      if (NS_FAILED(res)) return res;

      *aCanDrag = isTargetedCorrectly;
    }
  }

  if (NS_FAILED(res)) return res;
  if (!*aCanDrag) return NS_OK;

  nsCOMPtr<nsIDOMDocument> domdoc;
  GetDocument(getter_AddRefs(domdoc));
  *aCanDrag = nsEditorHookUtils::DoAllowDragHook(domdoc, aDragEvent);
  return NS_OK;
}

Here is the call graph for this function:

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

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

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.

NS_IMETHODIMP nsHTMLEditor::CanPaste ( PRInt32  aSelectionType,
PRBool aCanPaste 
)

Reimplemented from nsPlaintextEditor.

Definition at line 1964 of file nsHTMLDataTransfer.cpp.

{
  if (!aCanPaste)
    return NS_ERROR_NULL_POINTER;
  *aCanPaste = PR_FALSE;
  
  // can't paste if readonly
  if (!IsModifiable())
    return NS_OK;
    
  nsresult rv;
  nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
  if (NS_FAILED(rv)) return rv;
  
  // the flavors that we can deal with
  const char* const textEditorFlavors[] = { kUnicodeMime, nsnull };
  const char* const htmlEditorFlavors[] = { kHTMLMime, kJPEGImageMime, nsnull };

  nsCOMPtr<nsISupportsArray> flavorsList =
                           do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
  if (NS_FAILED(rv)) return rv;
  
  PRUint32 editorFlags;
  GetFlags(&editorFlags);
  
  // add the flavors for all editors
  for (const char* const* flavor = textEditorFlavors; *flavor; flavor++)
  {
    nsCOMPtr<nsISupportsCString> flavorString  = do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID);
    if (flavorString)
    {
      flavorString->SetData(nsDependentCString(*flavor));
      flavorsList->AppendElement(flavorString);
    }
  }
  
  // add the HTML-editor only flavors
  if ((editorFlags & eEditorPlaintextMask) == 0)
  {
    for (const char* const* htmlFlavor = htmlEditorFlavors;
         *htmlFlavor;
         htmlFlavor++)
    {
      nsCOMPtr<nsISupportsCString> flavorString  = do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID);
      if (flavorString)
      {
        flavorString->SetData(nsDependentCString(*htmlFlavor));
        flavorsList->AppendElement(flavorString);
      }
    }
  }
  
  PRBool haveFlavors;
  rv = clipboard->HasDataMatchingFlavors(flavorsList, aSelectionType, &haveFlavors);
  if (NS_FAILED(rv)) return rv;
  
  *aCanPaste = haveFlavors;
  return NS_OK;
}

Here is the call graph for this function:

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.
nsresult nsHTMLEditor::CheckPositionedElementBGandFG ( nsIDOMElement aElement,
nsAString &  aReturn 
) [protected]

Definition at line 648 of file nsHTMLAbsPosition.cpp.

{
  // we are going to outline the positioned element and bring it to the
  // front to overlap any other element intersecting with it. But
  // first, let's see what's the background and foreground colors of the
  // positioned element.
  // if background-image computed value is 'none,
  //   If the background color is 'auto' and R G B values of the foreground are
  //       each above #d0, use a black background
  //   If the background color is 'auto' and at least one of R G B values of
  //       the foreground is below #d0, use a white background
  // Otherwise don't change background/foreground

  aReturn.Truncate();
  
  nsAutoString bgImageStr;
  nsresult res =
    mHTMLCSSUtils->GetComputedProperty(aElement,
                                       nsEditProperty::cssBackgroundImage,
                                       bgImageStr);
  if (NS_FAILED(res)) return res;
  if (bgImageStr.EqualsLiteral("none")) {
    nsAutoString bgColorStr;
    res =
      mHTMLCSSUtils->GetComputedProperty(aElement,
                                         nsEditProperty::cssBackgroundColor,
                                         bgColorStr);
    if (NS_FAILED(res)) return res;
    if (bgColorStr.EqualsLiteral("transparent")) {

      nsCOMPtr<nsIDOMViewCSS> viewCSS;
      res = mHTMLCSSUtils->GetDefaultViewCSS(aElement, getter_AddRefs(viewCSS));
      if (NS_FAILED(res)) return res;
      nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
      res = viewCSS->GetComputedStyle(aElement, EmptyString(), getter_AddRefs(cssDecl));
      if (NS_FAILED(res)) return res;
      // from these declarations, get the one we want and that one only
      nsCOMPtr<nsIDOMCSSValue> colorCssValue;
      res = cssDecl->GetPropertyCSSValue(NS_LITERAL_STRING("color"), getter_AddRefs(colorCssValue));
      if (NS_FAILED(res)) return res;

      PRUint16 type;
      res = colorCssValue->GetCssValueType(&type);
      if (NS_FAILED(res)) return res;
      if (nsIDOMCSSValue::CSS_PRIMITIVE_VALUE == type) {
        nsCOMPtr<nsIDOMCSSPrimitiveValue> val = do_QueryInterface(colorCssValue);
        res = val->GetPrimitiveType(&type);
        if (NS_FAILED(res)) return res;
        if (nsIDOMCSSPrimitiveValue::CSS_RGBCOLOR == type) {
          nsCOMPtr<nsIDOMRGBColor> rgbColor;
          res = val->GetRGBColorValue(getter_AddRefs(rgbColor));
          if (NS_FAILED(res)) return res;
          nsCOMPtr<nsIDOMCSSPrimitiveValue> red, green, blue;
          float r, g, b;
          res = rgbColor->GetRed(getter_AddRefs(red));
          if (NS_FAILED(res)) return res;
          res = rgbColor->GetGreen(getter_AddRefs(green));
          if (NS_FAILED(res)) return res;
          res = rgbColor->GetBlue(getter_AddRefs(blue));
          if (NS_FAILED(res)) return res;
          res = red->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, &r);
          if (NS_FAILED(res)) return res;
          res = green->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, &g);
          if (NS_FAILED(res)) return res;
          res = blue->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, &b);
          if (NS_FAILED(res)) return res;
          if (r >= BLACK_BG_RGB_TRIGGER &&
              g >= BLACK_BG_RGB_TRIGGER &&
              b >= BLACK_BG_RGB_TRIGGER)
            aReturn.AssignLiteral("black");
          else
            aReturn.AssignLiteral("white");
          return NS_OK;
        }
      }
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Checks if the anonymous nodes created by the HTML editor have to be refreshed or hidden depending on a possible new state of the selection.

Parameters:
aSelection[IN] a selection

Definition at line 4448 of file nsHTMLEditor.cpp.

Here is the caller graph for this function:

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

join together any afjacent editable text nodes in the range

Definition at line 4491 of file nsHTMLEditor.cpp.

{
  if (!aInRange) return NS_ERROR_NULL_POINTER;
  nsAutoTxnsConserveSelection dontSpazMySelection(this);
  nsVoidArray textNodes;  // we can't actually do anything during iteration, so store the text nodes in an array
                          // don't bother ref counting them because we know we can hold them for the 
                          // lifetime of this method


  // build a list of editable text nodes
  nsresult result;
  nsCOMPtr<nsIContentIterator> iter =
    do_CreateInstance("@mozilla.org/content/subtree-content-iterator;1", &result);
  if (NS_FAILED(result)) return result;

  iter->Init(aInRange);

  while (!iter->IsDone())
  {
    nsIContent *content = iter->GetCurrentNode();  

    nsCOMPtr<nsIDOMCharacterData> text = do_QueryInterface(content);
    nsCOMPtr<nsIDOMNode>          node = do_QueryInterface(content);
    if (text && node && IsEditable(node))
    {
      textNodes.AppendElement(node.get());
    }

    iter->Next();
  }

  // now that I have a list of text nodes, collapse adjacent text nodes
  // NOTE: assumption that JoinNodes keeps the righthand node
  while (textNodes.Count() > 1)
  {
    // we assume a textNodes entry can't be nsnull
    nsIDOMNode *leftTextNode = (nsIDOMNode *)(textNodes.ElementAt(0));
    nsIDOMNode *rightTextNode = (nsIDOMNode *)(textNodes.ElementAt(1));
    NS_ASSERTION(leftTextNode && rightTextNode,"left or rightTextNode null in CollapseAdjacentTextNodes");

    // get the prev sibling of the right node, and see if it's leftTextNode
    nsCOMPtr<nsIDOMNode> prevSibOfRightNode;
    result = GetPriorHTMLSibling(rightTextNode, address_of(prevSibOfRightNode));
    if (NS_FAILED(result)) return result;
    if (prevSibOfRightNode && (prevSibOfRightNode == leftTextNode))
    {
      nsCOMPtr<nsIDOMNode> parent;
      result = rightTextNode->GetParentNode(getter_AddRefs(parent));
      if (NS_FAILED(result)) return result;
      if (!parent) return NS_ERROR_NULL_POINTER;
      result = JoinNodes(leftTextNode, rightTextNode, parent);
      if (NS_FAILED(result)) return result;
    }

    textNodes.RemoveElementAt(0); // remove the leftmost text node from the list
  }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1583 of file nsHTMLEditor.cpp.

{
  if (!aNode) return NS_ERROR_NULL_POINTER;
  nsresult res;

  nsCOMPtr<nsISelection> selection;
  if (aSelection)
  {
    selection = aSelection;
  } else {
    res = GetSelection(getter_AddRefs(selection));
    if (NS_FAILED(res)) return res;
    if (!selection) return NS_ERROR_FAILURE;
  }
  nsCOMPtr<nsIDOMNode> node = aNode;
  nsCOMPtr<nsIDOMNode> child;
  
  do {
    node->GetFirstChild(getter_AddRefs(child));
    
    if (child)
    {
      // Stop if we find a table
      // don't want to go into nested tables
      if (nsHTMLEditUtils::IsTable(child)) break;
      // hey, it'g gotta be a container too!
      if (!IsContainer(child)) break;
      node = child;
    }
  }
  while (child);

  selection->Collapse(node,0);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in nsHTMLEditorLog.

Definition at line 1099 of file nsPlaintextEditor.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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?

nsresult nsHTMLEditor::CopyCellBackgroundColor ( nsIDOMElement destCell,
nsIDOMElement sourceCell 
) [protected]

Definition at line 1868 of file nsTableEditor.cpp.

{
  if (!destCell || !sourceCell) return NS_ERROR_NULL_POINTER;

  // Copy backgournd color to new cell
  NS_NAMED_LITERAL_STRING(bgcolor, "bgcolor");
  nsAutoString color;
  PRBool isSet;
  nsresult res = GetAttributeValue(sourceCell, bgcolor, color, &isSet);

  if (NS_SUCCEEDED(res) && isSet)
    res = SetAttribute(destCell, bgcolor, color);

  return res;
}

Here is the caller graph for this function:

NS_IMETHODIMP nsHTMLEditor::CopyLastEditableChildStyles ( nsIDOMNode aPreviousBlock,
nsIDOMNode aNewBlock,
nsIDOMNode **  aOutBrNode 
)

Definition at line 5629 of file nsHTMLEditor.cpp.

{
  *aOutBrNode = nsnull;
  nsCOMPtr<nsIDOMNode> child, tmp;
  nsresult res;
  // first, clear out aNewBlock.  Contract is that we want only the styles from previousBlock.
  res = aNewBlock->GetFirstChild(getter_AddRefs(child));
  while (NS_SUCCEEDED(res) && child)
  {
    res = DeleteNode(child);
    if (NS_FAILED(res)) return res;
    res = aNewBlock->GetFirstChild(getter_AddRefs(child));
  }
  // now find and clone the styles
  child = aPreviousBlock;
  tmp = aPreviousBlock;
  while (tmp) {
    child = tmp;
    res = GetLastEditableChild(child, address_of(tmp));
    if (NS_FAILED(res)) return res;
  }
  while (child && nsTextEditUtils::IsBreak(child)) {
    nsCOMPtr<nsIDOMNode> priorNode;
    res = GetPriorHTMLNode(child, address_of(priorNode));
    if (NS_FAILED(res)) return res;
    child = priorNode;
  }
  nsCOMPtr<nsIDOMNode> newStyles = nsnull, deepestStyle = nsnull;
  while (child && (child != aPreviousBlock)) {
    if (nsHTMLEditUtils::IsInlineStyle(child) ||
        nsEditor::NodeIsType(child, nsEditProperty::span)) {
      nsAutoString domTagName;
      child->GetNodeName(domTagName);
      ToLowerCase(domTagName);
      if (newStyles) {
        nsCOMPtr<nsIDOMNode> newContainer;
        res = InsertContainerAbove(newStyles, address_of(newContainer), domTagName);
        if (NS_FAILED(res)) return res;
        newStyles = newContainer;
      }
      else {
        res = CreateNode(domTagName, aNewBlock, 0, getter_AddRefs(newStyles));
        if (NS_FAILED(res)) return res;
        deepestStyle = newStyles;
      }
      res = CloneAttributes(newStyles, child);
      if (NS_FAILED(res)) return res;
    }
    nsCOMPtr<nsIDOMNode> tmp;
    res = child->GetParentNode(getter_AddRefs(tmp));
    if (NS_FAILED(res)) return res;
    child = tmp;
  }
  if (deepestStyle) {
    nsCOMPtr<nsIDOMNode> outBRNode;
    res = CreateBR(deepestStyle, 0, address_of(outBRNode));
    if (NS_FAILED(res)) return res;
    // Getters must addref
    *aOutBrNode = outBRNode;
    NS_ADDREF(*aOutBrNode);
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEditor::CountEditableChildren ( nsIDOMNode aNode,
PRUint32 outCount 
) [inherited]

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:

nsIDOMElement nsIHTMLEditor::createAnonymousElement ( in AString  aTag,
in nsIDOMNode  aParentNode,
in AString  aAnonClass,
in boolean  aIsCreatedHidden 
) [inherited]

Returns an anonymous nsDOMElement of type aTag, child of aParentNode.

If aIsCreatedHidden is true, the class "hidden" is added to the created element. If aAnonClass is not the empty string, it becomes the value of the attribute "_moz_anonclass"

Returns:
a DOM Element
Parameters:
aTag[IN] a string representing the desired type of the element to create
aParentNode[IN] the parent node of the created anonymous element
aAnonClass[IN] contents of the _moz_anonclass attribute
aIsCreatedHidden[IN] a boolean specifying if the class "hidden" is to be added to the created anonymous element
NS_IMETHODIMP nsHTMLEditor::CreateBR ( nsIDOMNode aNode,
PRInt32  aOffset,
nsCOMPtr< nsIDOMNode > *  outBRNode,
nsIEditor::EDirection  aSelect = nsIEditor::eNone 
) [protected]

Reimplemented from nsPlaintextEditor.

Definition at line 1537 of file nsHTMLEditor.cpp.

{
  nsCOMPtr<nsIDOMNode> parent = aNode;
  PRInt32 offset = aOffset;
  return CreateBRImpl(address_of(parent), &offset, outBRNode, aSelect);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsHTMLEditor::CreateBRImpl ( nsCOMPtr< nsIDOMNode > *  aInOutParent,
PRInt32 aInOutOffset,
nsCOMPtr< nsIDOMNode > *  outBRNode,
nsIEditor::EDirection  aSelect 
) [protected]

Reimplemented from nsPlaintextEditor.

Definition at line 1456 of file nsHTMLEditor.cpp.

{
  if (!aInOutParent || !*aInOutParent || !aInOutOffset || !outBRNode) return NS_ERROR_NULL_POINTER;
  *outBRNode = nsnull;
  nsresult res;
  
  // we need to insert a br.  unfortunately, we may have to split a text node to do it.
  nsCOMPtr<nsIDOMNode> node = *aInOutParent;
  PRInt32 theOffset = *aInOutOffset;
  nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(node);
  NS_NAMED_LITERAL_STRING(brType, "br");
  nsCOMPtr<nsIDOMNode> brNode;
  if (nodeAsText)  
  {
    nsCOMPtr<nsIDOMNode> tmp;
    PRInt32 offset;
    PRUint32 len;
    nodeAsText->GetLength(&len);
    GetNodeLocation(node, address_of(tmp), &offset);
    if (!tmp) return NS_ERROR_FAILURE;
    if (!theOffset)
    {
      // we are already set to go
    }
    else if (theOffset == (PRInt32)len)
    {
      // update offset to point AFTER the text node
      offset++;
    }
    else
    {
      // split the text node
      res = SplitNode(node, theOffset, getter_AddRefs(tmp));
      if (NS_FAILED(res)) return res;
      res = GetNodeLocation(node, address_of(tmp), &offset);
      if (NS_FAILED(res)) return res;
    }
    // create br
    res = CreateNode(brType, tmp, offset, getter_AddRefs(brNode));
    if (NS_FAILED(res)) return res;
    *aInOutParent = tmp;
    *aInOutOffset = offset+1;
  }
  else
  {
    res = CreateNode(brType, node, theOffset, getter_AddRefs(brNode));
    if (NS_FAILED(res)) return res;
    (*aInOutOffset)++;
  }

  *outBRNode = brNode;
  if (*outBRNode && (aSelect != eNone))
  {
    nsCOMPtr<nsISelection> selection;
    nsCOMPtr<nsIDOMNode> parent;
    PRInt32 offset;
    res = GetSelection(getter_AddRefs(selection));
    if (NS_FAILED(res)) return res;
    nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
    res = GetNodeLocation(*outBRNode, address_of(parent), &offset);
    if (NS_FAILED(res)) return res;
    if (aSelect == eNext)
    {
      // position selection after br
      selPriv->SetInterlinePosition(PR_TRUE);
      res = selection->Collapse(parent, offset+1);
    }
    else if (aSelect == ePrevious)
    {
      // position selection before br
      selPriv->SetInterlinePosition(PR_TRUE);
      res = selection->Collapse(parent, offset);
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsHTMLEditor::CreateDOMFragmentFromPaste ( const nsAString &  aInputString,
const nsAString &  aContextStr,
const nsAString &  aInfoStr,
nsCOMPtr< nsIDOMNode > *  outFragNode,
PRInt32 outRangeStartHint,
PRInt32 outRangeEndHint 
) [protected]

Definition at line 2484 of file nsHTMLDataTransfer.cpp.

{
  if (!outFragNode || !outRangeStartHint || !outRangeEndHint) 
    return NS_ERROR_NULL_POINTER;
  nsCOMPtr<nsIDOMDocumentFragment> docfrag;
  nsCOMPtr<nsIDOMNode> contextAsNode, tmp;  
  nsresult res = NS_OK;

  nsCOMPtr<nsIDOMDocument> domDoc;
  GetDocument(getter_AddRefs(domDoc));

  nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
  NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
  
  // if we have context info, create a fragment for that
  nsVoidArray tagStack;
  nsCOMPtr<nsIDOMDocumentFragment> contextfrag;
  nsCOMPtr<nsIDOMNode> contextLeaf, junk;
  PRInt32 contextDepth = 0;
  if (!aContextStr.IsEmpty())
  {
    res = ParseFragment(aContextStr, tagStack, doc, address_of(contextAsNode));
    NS_ENSURE_SUCCESS(res, res);
    NS_ENSURE_TRUE(contextAsNode, NS_ERROR_FAILURE);

    res = StripFormattingNodes(contextAsNode);
    NS_ENSURE_SUCCESS(res, res);
    
    RemoveBodyAndHead(contextAsNode);
    
    // cache the deepest leaf in the context
    tmp = contextAsNode;
    while (tmp)
    {
      contextDepth++;
      contextLeaf = tmp;
      contextLeaf->GetFirstChild(getter_AddRefs(tmp));
    }
  }
 
  // get the tagstack for the context
  res = CreateTagStack(tagStack, contextLeaf);
  if (NS_FAILED(res))
  {
    FreeTagStackStrings(tagStack);
    return res;
  }
  // create fragment for pasted html
  res = ParseFragment(aInputString, tagStack, doc, outFragNode);
  FreeTagStackStrings(tagStack);
  NS_ENSURE_SUCCESS(res, res);
  NS_ENSURE_TRUE(*outFragNode, NS_ERROR_FAILURE);
      
  RemoveBodyAndHead(*outFragNode);
  
  if (contextAsNode)
  {
    // unite the two trees
    contextLeaf->AppendChild(*outFragNode, getter_AddRefs(junk));
    *outFragNode = contextAsNode;
    // no longer have fragmentAsNode in tree
    contextDepth--;
  }
 
  res = StripFormattingNodes(*outFragNode, PR_TRUE);
  NS_ENSURE_SUCCESS(res, res);
 
  // get the infoString contents
  nsAutoString numstr1, numstr2;
  if (!aInfoStr.IsEmpty())
  {
    PRInt32 err, sep;
    sep = aInfoStr.FindChar((PRUnichar)',');
    numstr1 = Substring(aInfoStr, 0, sep);
    numstr2 = Substring(aInfoStr, sep+1, aInfoStr.Length() - (sep+1));
    *outRangeStartHint = numstr1.ToInteger(&err) + contextDepth;
    *outRangeEndHint   = numstr2.ToInteger(&err) + contextDepth;
  }
  else
  {
    *outRangeStartHint = contextDepth;
    *outRangeEndHint = contextDepth;
  }
  return res;
}

Here is the call graph for this function:

nsIDOMElement nsIHTMLEditor::createElementWithDefaults ( in AString  aTagName) [inherited]

Return a new element with default attribute values.

This does not rely on the selection, and is not sensitive to context.

Used primarily to supply new element for various insert element dialogs (Image, Link, NamedAnchor, Table, and HorizontalRule are the only returned elements as of 7/25/99)

Parameters:
aTagNameThe HTML tagname Special input values for Links and Named anchors: Use "href" to get a link node (an "A" tag with the "href" attribute set) Use "anchor" or "namedanchor" to get a named anchor node (an "A" tag with the "name" attribute set)
Returns:
The new element created.
nsresult nsHTMLEditor::CreateEventListeners ( ) [protected, virtual]

Reimplemented from nsPlaintextEditor.

Definition at line 356 of file nsHTMLEditor.cpp.

{
  nsresult rv = NS_OK;

  if (!mMouseListenerP)
  {
    // get a mouse listener
    rv = NS_NewHTMLEditorMouseListener(getter_AddRefs(mMouseListenerP), this);

    if (NS_FAILED(rv))
    {
      return rv;
    }
  }

  return nsPlaintextEditor::CreateEventListeners();
}

Here is the call graph for this function:

nsresult nsHTMLEditor::CreateGrabber ( nsIDOMNode aParentNode,
nsIDOMElement **  aReturn 
) [protected]

Definition at line 263 of file nsHTMLAbsPosition.cpp.

{
  // let's create a grabber through the element factory
  nsresult res = CreateAnonymousElement(NS_LITERAL_STRING("span"),
                                        aParentNode,
                                        NS_LITERAL_STRING("mozGrabber"),
                                        PR_FALSE,
                                        aReturn);

  if (!*aReturn)
    return NS_ERROR_FAILURE;

  // add the mouse listener so we can detect a click on a resizer
  nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(*aReturn));
  evtTarget->AddEventListener(NS_LITERAL_STRING("mousedown"), mMouseListenerP, PR_FALSE);

  return res;
}

Here is the call graph for this function:

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

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:

nsresult nsHTMLEditor::CreateListOfNodesToPaste ( nsIDOMNode aFragmentAsNode,
nsCOMArray< nsIDOMNode > &  outNodeList,
nsIDOMNode aStartNode,
PRInt32  aStartOffset,
nsIDOMNode aEndNode,
PRInt32  aEndOffset 
) [protected]

Definition at line 2670 of file nsHTMLDataTransfer.cpp.

{
  if (!aFragmentAsNode) 
    return NS_ERROR_NULL_POINTER;

  nsresult res;

  // if no info was provided about the boundary between context and stream,
  // then assume all is stream.
  if (!aStartNode)
  {
    PRInt32 fragLen;
    res = GetLengthOfDOMNode(aFragmentAsNode, (PRUint32&)fragLen);
    NS_ENSURE_SUCCESS(res, res);

    aStartNode = aFragmentAsNode;
    aStartOffset = 0;
    aEndNode = aFragmentAsNode;
    aEndOffset = fragLen;
  }

  nsCOMPtr<nsIDOMRange> docFragRange =
                          do_CreateInstance("@mozilla.org/content/range;1");
  if (!docFragRange) return NS_ERROR_OUT_OF_MEMORY;

  res = docFragRange->SetStart(aStartNode, aStartOffset);
  NS_ENSURE_SUCCESS(res, res);
  res = docFragRange->SetEnd(aEndNode, aEndOffset);
  NS_ENSURE_SUCCESS(res, res);

  // now use a subtree iterator over the range to create a list of nodes
  nsTrivialFunctor functor;
  nsDOMSubtreeIterator iter;
  res = iter.Init(docFragRange);
  NS_ENSURE_SUCCESS(res, res);
  res = iter.AppendList(functor, outNodeList);

  return res;
}

Here is the call 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 
) [inherited]

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:

nsresult nsHTMLEditor::CreateResizer ( nsIDOMElement **  aReturn,
PRInt16  aLocation,
nsIDOMNode aParentNode 
) [protected]

Definition at line 183 of file nsHTMLObjectResizer.cpp.

{
  nsresult res = CreateAnonymousElement(NS_LITERAL_STRING("span"),
                                        aParentNode,
                                        NS_LITERAL_STRING("mozResizer"),
                                        PR_FALSE,
                                        aReturn);

  if (NS_FAILED(res)) return res;
  if (!*aReturn)
    return NS_ERROR_FAILURE;

  // add the mouse listener so we can detect a click on a resizer
  nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(*aReturn));
  evtTarget->AddEventListener(NS_LITERAL_STRING("mousedown"), mMouseListenerP, PR_TRUE);

  nsAutoString locationStr;
  switch (aLocation) {
    case nsIHTMLObjectResizer::eTopLeft:
      locationStr = kTopLeft;
      break;
    case nsIHTMLObjectResizer::eTop:
      locationStr = kTop;
      break;
    case nsIHTMLObjectResizer::eTopRight:
      locationStr = kTopRight;
      break;

    case nsIHTMLObjectResizer::eLeft:
      locationStr = kLeft;
      break;
    case nsIHTMLObjectResizer::eRight:
      locationStr = kRight;
      break;

    case nsIHTMLObjectResizer::eBottomLeft:
      locationStr = kBottomLeft;
      break;
    case nsIHTMLObjectResizer::eBottom:
      locationStr = kBottom;
      break;
    case nsIHTMLObjectResizer::eBottomRight:
      locationStr = kBottomRight;
      break;
  }

  res = (*aReturn)->SetAttribute(NS_LITERAL_STRING("anonlocation"),
                                 locationStr);
  return res;
}

Here is the call graph for this function:

nsresult nsHTMLEditor::CreateResizingInfo ( nsIDOMElement **  aReturn,
nsIDOMNode aParentNode 
) [protected]

Definition at line 257 of file nsHTMLObjectResizer.cpp.

{
  // let's create an info box through the element factory
  nsresult res = CreateAnonymousElement(NS_LITERAL_STRING("span"),
                                        aParentNode,
                                        NS_LITERAL_STRING("mozResizingInfo"),
                                        PR_TRUE,
                                        aReturn);

  if (!*aReturn)
    return NS_ERROR_FAILURE;

  return res;
}
nsresult nsHTMLEditor::CreateShadow ( nsIDOMElement **  aReturn,
nsIDOMNode aParentNode,
nsIDOMElement aOriginalObject 
) [protected]

Definition at line 235 of file nsHTMLObjectResizer.cpp.

{
  // let's create an image through the element factory
  nsAutoString name;
  if (nsHTMLEditUtils::IsImage(aOriginalObject))
    name.AssignLiteral("img");
  else
    name.AssignLiteral("span");
  nsresult res = CreateAnonymousElement(name,
                                        aParentNode,
                                        NS_LITERAL_STRING("mozResizingShadow"),
                                        PR_TRUE,
                                        aReturn);

  if (!*aReturn)
    return NS_ERROR_FAILURE;

  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsHTMLEditor::CreateTagStack ( nsVoidArray aTagStack,
nsIDOMNode aNode 
) [protected]

Definition at line 2618 of file nsHTMLDataTransfer.cpp.

{
  nsresult res = NS_OK;
  nsCOMPtr<nsIDOMNode> node= aNode;
  PRBool bSeenBody = PR_FALSE;
  
  while (node) 
  {
    if (nsTextEditUtils::IsBody(node))
      bSeenBody = PR_TRUE;
    nsCOMPtr<nsIDOMNode> temp = node;
    PRUint16 nodeType;
    
    node->GetNodeType(&nodeType);
    if (nsIDOMNode::ELEMENT_NODE == nodeType)
    {
      nsAutoString tagName;
      node->GetNodeName(tagName);
      // XXX Wish we didn't have to allocate here
      PRUnichar* name = ToNewUnicode(tagName);
      if (!name) 
             return NS_ERROR_OUT_OF_MEMORY;

      aTagStack.AppendElement(name);
      // printf("%s\n",NS_LossyConvertUCS2toASCII(tagName).get());
    }

    res = temp->GetParentNode(getter_AddRefs(node));
    NS_ENSURE_SUCCESS(res, res);  
  }
  
  if (!bSeenBody)
  {
      PRUnichar* bodyname = ToNewUnicode(NS_LITERAL_STRING("BODY"));
      aTagStack.AppendElement(bodyname);
  }
  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsEditor::CreateTxnForAddStyleSheet ( nsICSSStyleSheet aSheet,
AddStyleSheetTxn **  aTxn 
) [protected, inherited]

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, inherited]

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:

NS_IMETHODIMP nsEditor::CreateTxnForDeleteElement ( nsIDOMNode aElement,
DeleteElementTxn **  aTxn 
) [protected, inherited]

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, inherited]

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, inherited]

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, inherited]

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, inherited]

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, inherited]

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, inherited]

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, inherited]

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, inherited]

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:

Reimplemented in nsHTMLEditorLog.

Definition at line 1073 of file nsPlaintextEditor.cpp.

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

  PRBool isCollapsed;
  if (NS_SUCCEEDED(selection->GetIsCollapsed(&isCollapsed)) && isCollapsed)
    return NS_OK;  // just return ok so no JS error is thrown

  res = Copy();
  if (NS_SUCCEEDED(res))
    res = DeleteSelection(eNone);
  return res;
}

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.

NS_IMETHODIMP nsHTMLEditor::DebugUnitTests ( PRInt32 outNumTests,
PRInt32 outNumTestsFailed 
)

Definition at line 4033 of file nsHTMLEditor.cpp.

{
#ifdef DEBUG
  if (!outNumTests || !outNumTestsFailed)
    return NS_ERROR_NULL_POINTER;

  TextEditorTest *tester = new TextEditorTest();
  if (!tester)
    return NS_ERROR_OUT_OF_MEMORY;
   
  tester->Run(this, outNumTests, outNumTestsFailed);
  delete tester;
  return NS_OK;
#else
  return NS_ERROR_NOT_IMPLEMENTED;
#endif
}
void nsIEditor::debugUnitTests ( out long  outNumTests,
out long  outNumTestsFailed 
) [inherited]

Decrease font size for text in selection by 1 HTML unit All existing text is scanned for existing <FONT size>=""> attributes so they will be decreased instead of inserting new <FONT> tag.

Definition at line 1084 of file nsTableEditor.cpp.

{
  if (!aCell) return NS_ERROR_NULL_POINTER;

  // Prevent rules testing until we're done
  nsAutoRules beginRulesSniffing(this, kOpDeleteNode, nsIEditor::eNext);

  nsCOMPtr<nsIDOMNode> child;
  PRBool hasChild;
  aCell->HasChildNodes(&hasChild);

  while (hasChild)
  {
    aCell->GetLastChild(getter_AddRefs(child));
    nsresult res = DeleteNode(child);
    if (NS_FAILED(res)) return res;
    aCell->HasChildNodes(&hasChild);
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsHTMLEditor::DeleteColumn ( nsIDOMElement aTable,
PRInt32  aColIndex 
) [protected]

Definition at line 1190 of file nsTableEditor.cpp.

{
  if (!aTable) return NS_ERROR_NULL_POINTER;

  nsCOMPtr<nsIDOMElement> cell;
  nsCOMPtr<nsIDOMElement> cellInDeleteCol;
  PRInt32 startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
  PRBool  isSelected;
  PRInt32 rowIndex = 0;
  nsresult res = NS_OK;
   
  do {
    res = GetCellDataAt(aTable, rowIndex, aColIndex, getter_AddRefs(cell),
                        &startRowIndex, &startColIndex, &rowSpan, &colSpan, 
                        &actualRowSpan, &actualColSpan, &isSelected);

    if (NS_FAILED(res)) return res;

    if (cell)
    {
      // Find cells that don't start in column we are deleting
      if (startColIndex < aColIndex || colSpan > 1 || colSpan == 0)
      {
        // We have a cell spanning this location
        // Decrease its colspan to keep table rectangular,
        // but if colSpan=0, it will adjust automatically
        if (colSpan > 0)
        {
          NS_ASSERTION((colSpan > 1),"Bad COLSPAN in DeleteTableColumn");
          SetColSpan(cell, colSpan-1);
        }
        if (startColIndex == aColIndex)
        {
          // Cell is in column to be deleted, but must have colspan > 1,
          // so delete contents of cell instead of cell itself
          // (We must have reset colspan above)
          DeleteCellContents(cell);
        }
        // To next cell in column
        rowIndex += actualRowSpan;
      } 
      else 
      {
        // Delete the cell
        if (1 == GetNumberOfCellsInRow(aTable, rowIndex))
        {
          // Only 1 cell in row - delete the row
          nsCOMPtr<nsIDOMElement> parentRow;
          res = GetElementOrParentByTagName(NS_LITERAL_STRING("tr"), cell, getter_AddRefs(parentRow));
          if (NS_FAILED(res)) return res;
          if(!parentRow) return NS_ERROR_NULL_POINTER;

          //  But first check if its the only row left
          //  so we can delete the entire table
          //  (This should never happen but it's the safe thing to do)
          PRInt32 rowCount, colCount;
          res = GetTableSize(aTable, &rowCount, &colCount);
          if (NS_FAILED(res)) return res;

          if (rowCount == 1)
          {
            nsCOMPtr<nsISelection> selection;
            res = GetSelection(getter_AddRefs(selection));
            if (NS_FAILED(res)) return res;
            if (!selection) return NS_ERROR_FAILURE;
            return DeleteTable2(aTable, selection);
          }
    
          // Delete the row by placing caret in cell we were to delete
          // We need to call DeleteTableRow to handle cells with rowspan 
          res = DeleteRow(aTable, startRowIndex);
          if (NS_FAILED(res)) return res;

          // Note that we don't incremenet rowIndex
          // since a row was deleted and "next" 
          // row now has current rowIndex
        } 
        else 
        {
          // A more "normal" deletion
          res = DeleteNode(cell);
          if (NS_FAILED(res)) return res;

          //Skip over any rows spanned by this cell
          rowIndex += actualRowSpan;
        }
      }
    }
  } while (cell);    

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3883 of file nsHTMLEditor.cpp.

{
  nsCOMPtr<nsIDOMNode> selectAllNode = FindUserSelectAllNode(aNode);
  
  if (selectAllNode)
  {
    return nsEditor::DeleteNode(selectAllNode);
  }
  return nsEditor::DeleteNode(aNode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIEditor::deleteNode ( in nsIDOMNode  child) [inherited]

deleteNode removes aChild from aParent.

Parameters:
aChildThe node to delete
void nsHTMLEditor::DeleteRefToAnonymousNode ( nsIDOMElement aElement,
nsIContent aParentContent,
nsIPresShell aShell 
) [protected]

Definition at line 190 of file nsHTMLAnonymousUtils.cpp.

{
  // call ContentRemoved() for the anonymous content
  // node so its references get removed from the frame manager's
  // undisplay map, and its layout frames get destroyed!

  if (aElement) {
    nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
    if (content) {
      // Need to check whether aShell has been destroyed (but not yet deleted).
      // In that case presContext->GetPresShell() returns nsnull.
      // See bug 338129.
      if (aShell && aShell->GetPresContext() &&
          aShell->GetPresContext()->GetPresShell() == aShell) {
        nsCOMPtr<nsIDocumentObserver> docObserver = do_QueryInterface(aShell);
        if (docObserver) {
          docObserver->ContentRemoved(content->GetCurrentDoc(),
                                      aParentContent, content, -1);
        }
      }
      content->UnbindFromTree();
    }
  }
}  

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsHTMLEditor::DeleteRow ( nsIDOMElement aTable,
PRInt32  aRowIndex 
) [protected]

Definition at line 1384 of file nsTableEditor.cpp.

{
  if (!aTable) return NS_ERROR_NULL_POINTER;

  nsCOMPtr<nsIDOMElement> cell;
  nsCOMPtr<nsIDOMElement> cellInDeleteRow;
  PRInt32 startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
  PRBool  isSelected;
  PRInt32 colIndex = 0;
  nsresult res = NS_OK;
   
  // Prevent rules testing until we're done
  nsAutoRules beginRulesSniffing(this, kOpDeleteNode, nsIEditor::eNext);

  // The list of cells we will change rowspan in
  //  and the new rowspan values for each
  nsVoidArray spanCellList;
  nsVoidArray newSpanList;

  // Scan through cells in row to do rowspan adjustments
  // Note that after we delete row, startRowIndex will point to the
  //   cells in the next row to be deleted
  do {
    res = GetCellDataAt(aTable, aRowIndex, colIndex, getter_AddRefs(cell),
                        &startRowIndex, &startColIndex, &rowSpan, &colSpan, 
                        &actualRowSpan, &actualColSpan, &isSelected);
  
    // We don't fail if we don't find a cell, so this must be real bad
    if(NS_FAILED(res)) return res;

    // Compensate for cells that don't start or extend below the row we are deleting
    if (cell)
    {
      if (startRowIndex < aRowIndex)
      {
        // Cell starts in row above us
        // Decrease its rowspan to keep table rectangular
        //  but we don't need to do this if rowspan=0,
        //  since it will automatically adjust
        if (rowSpan > 0)
        {
          // Build list of cells to change rowspan
          // We can't do it now since it upsets cell map,
          //  so we will do it after deleting the row
          spanCellList.AppendElement((void*)cell.get());
          newSpanList.AppendElement((void*)PR_MAX((aRowIndex - startRowIndex), actualRowSpan-1));
        }
      }
      else 
      {
        if (rowSpan > 1)
        {
          //Cell spans below row to delete,
          //  so we must insert new cells to keep rows below even
          // Note that we test "rowSpan" so we don't do this if rowSpan = 0 (automatic readjustment)
          res = SplitCellIntoRows(aTable, startRowIndex, startColIndex,
                                  aRowIndex - startRowIndex + 1, // The row above the row to insert new cell into
                                  actualRowSpan - 1, nsnull);    // Span remaining below
          if (NS_FAILED(res)) return res;
        }
        if (!cellInDeleteRow)
          cellInDeleteRow = cell; // Reference cell to find row to delete
      }
      // Skip over other columns spanned by this cell
      colIndex += actualColSpan;
    }
  } while (cell);

  // Things are messed up if we didn't find a cell in the row!
  if (!cellInDeleteRow)
    return NS_ERROR_FAILURE;

  // Delete the entire row
  nsCOMPtr<nsIDOMElement> parentRow;
  res = GetElementOrParentByTagName(NS_LITERAL_STRING("tr"), cellInDeleteRow, getter_AddRefs(parentRow));
  if (NS_FAILED(res)) return res;

  if (parentRow)
  {
    res = DeleteNode(parentRow);
    if (NS_FAILED(res)) return res;
  }

  // Now we can set new rowspans for cells stored above  
  nsIDOMElement *cellPtr;
  PRInt32 newSpan;
  PRInt32 count;
  while ((count = spanCellList.Count()))
  {
    // go backwards to keep nsVoidArray from mem-moving everything each time
    count--; // nsVoidArray is zero based
    cellPtr = (nsIDOMElement*)spanCellList.ElementAt(count);
    spanCellList.RemoveElementAt(count);
    newSpan = NS_PTR_TO_INT32(newSpanList.ElementAt(count));
    newSpanList.RemoveElementAt(count);
    if (cellPtr)
    {
      res = SetRowSpan(cellPtr, newSpan);
      if (NS_FAILED(res)) return res;
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in nsHTMLEditorLog.

Definition at line 616 of file nsPlaintextEditor.cpp.

{
  if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }

  nsresult result;

  // delete placeholder txns merge.
  nsAutoPlaceHolderBatch batch(this, gDeleteTxnName);
  nsAutoRules beginRulesSniffing(this, kOpDeleteSelection, aAction);

  // If it's one of these modes,
  // we have to extend the selection first.
  // This needs to happen inside selection batching,
  // otherwise the deleted text is autocopied to the clipboard.
  if (aAction == eNextWord || aAction == ePreviousWord
      || aAction == eToBeginningOfLine || aAction == eToEndOfLine)
  {
    if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
    nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
    if (!ps) return NS_ERROR_NOT_INITIALIZED;

    PRUint8 caretBidiLevel;
    result = ps->GetCaretBidiLevel(&caretBidiLevel);
    if (NS_FAILED(result)) return result;
    
    nsCOMPtr<nsISelectionController> selCont (do_QueryReferent(mSelConWeak));
    if (!selCont)
      return NS_ERROR_NO_INTERFACE;

    switch (aAction)
    {
        // if caret has odd Bidi level, i.e. text is right-to-left,
        // reverse the effect of ePreviousWord and eNextWord
        case eNextWord:
          result = (caretBidiLevel & 1) ?
                   selCont->WordMove(PR_FALSE, PR_TRUE) :
                   selCont->WordMove(PR_TRUE, PR_TRUE);
          // DeleteSelectionImpl doesn't handle these actions
          // because it's inside batching, so don't confuse it:
          aAction = eNone;
          break;
        case ePreviousWord:
          result = (caretBidiLevel & 1) ?
                   selCont->WordMove(PR_TRUE, PR_TRUE) :
                   selCont->WordMove(