michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsHTMLEditor_h__ michael@0: #define nsHTMLEditor_h__ michael@0: michael@0: #include "nsCOMPtr.h" michael@0: #include "nsCOMArray.h" michael@0: #include "nsPlaintextEditor.h" michael@0: #include "nsIEditor.h" michael@0: #include "nsIHTMLEditor.h" michael@0: #include "nsITableEditor.h" michael@0: #include "nsIEditorMailSupport.h" michael@0: #include "nsIEditorStyleSheets.h" michael@0: michael@0: #include "nsEditor.h" michael@0: #include "nsIDOMElement.h" michael@0: #include "nsIDOMEventListener.h" michael@0: #include "nsICSSLoaderObserver.h" michael@0: michael@0: #include "nsEditRules.h" michael@0: michael@0: #include "nsEditProperty.h" michael@0: #include "nsHTMLCSSUtils.h" michael@0: michael@0: #include "nsHTMLObjectResizer.h" michael@0: #include "nsIHTMLAbsPosEditor.h" michael@0: #include "nsIHTMLInlineTableEditor.h" michael@0: #include "nsIHTMLObjectResizeListener.h" michael@0: #include "nsIHTMLObjectResizer.h" michael@0: michael@0: #include "nsIDocumentObserver.h" michael@0: michael@0: #include "nsPoint.h" michael@0: #include "nsTArray.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsAttrName.h" michael@0: #include "nsStubMutationObserver.h" michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/dom/Element.h" michael@0: michael@0: class nsIDOMKeyEvent; michael@0: class nsITransferable; michael@0: class nsIDocumentEncoder; michael@0: class nsIClipboard; michael@0: class TypeInState; michael@0: class nsIContentFilter; michael@0: class nsIURL; michael@0: class nsILinkHandler; michael@0: class nsTableOuterFrame; michael@0: struct PropItem; michael@0: michael@0: namespace mozilla { michael@0: namespace widget { michael@0: struct IMEState; michael@0: } // namespace widget michael@0: } // namespace mozilla michael@0: michael@0: /** michael@0: * The HTML editor implementation.
michael@0: * Use to edit HTML document represented as a DOM tree. michael@0: */ michael@0: class nsHTMLEditor : public nsPlaintextEditor, michael@0: public nsIHTMLEditor, michael@0: public nsIHTMLObjectResizer, michael@0: public nsIHTMLAbsPosEditor, michael@0: public nsITableEditor, michael@0: public nsIHTMLInlineTableEditor, michael@0: public nsIEditorStyleSheets, michael@0: public nsICSSLoaderObserver, michael@0: public nsStubMutationObserver michael@0: { michael@0: typedef enum {eNoOp, eReplaceParent=1, eInsertParent=2} BlockTransformationType; michael@0: michael@0: public: michael@0: michael@0: enum ResizingRequestID michael@0: { michael@0: kX = 0, michael@0: kY = 1, michael@0: kWidth = 2, michael@0: kHeight = 3 michael@0: }; michael@0: michael@0: // see nsIHTMLEditor for documentation michael@0: michael@0: //Interfaces for addref and release and queryinterface michael@0: //NOTE macro used is for classes that inherit from michael@0: // another class. Only the base class should use NS_DECL_ISUPPORTS michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLEditor, nsPlaintextEditor) michael@0: michael@0: michael@0: nsHTMLEditor(); michael@0: virtual ~nsHTMLEditor(); michael@0: michael@0: bool GetReturnInParagraphCreatesNewParagraph(); michael@0: michael@0: /* ------------ nsPlaintextEditor overrides -------------- */ michael@0: NS_IMETHOD GetIsDocumentEditable(bool *aIsDocumentEditable); michael@0: NS_IMETHOD BeginningOfDocument(); michael@0: virtual nsresult HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent); michael@0: virtual already_AddRefed GetFocusedContent(); michael@0: virtual already_AddRefed GetFocusedContentForIME(); michael@0: virtual bool IsActiveInDOMWindow(); michael@0: virtual already_AddRefed GetDOMEventTarget(); michael@0: virtual mozilla::dom::Element* GetEditorRoot() MOZ_OVERRIDE; michael@0: virtual already_AddRefed FindSelectionRoot(nsINode *aNode); michael@0: virtual bool IsAcceptableInputEvent(nsIDOMEvent* aEvent); michael@0: virtual already_AddRefed GetInputEventTargetContent(); michael@0: virtual bool IsEditable(nsIContent *aNode); michael@0: using nsEditor::IsEditable; michael@0: michael@0: /* ------------ nsStubMutationObserver overrides --------- */ michael@0: NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED michael@0: NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED michael@0: NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED michael@0: michael@0: /* ------------ nsIEditorIMESupport overrides ------------ */ michael@0: NS_IMETHOD GetPreferredIMEState(mozilla::widget::IMEState *aState); michael@0: michael@0: /* ------------ nsIHTMLEditor methods -------------- */ michael@0: michael@0: NS_DECL_NSIHTMLEDITOR michael@0: michael@0: /* ------------ nsIHTMLObjectResizer methods -------------- */ michael@0: /* -------- Implemented in nsHTMLObjectResizer.cpp -------- */ michael@0: NS_DECL_NSIHTMLOBJECTRESIZER michael@0: michael@0: /* ------------ nsIHTMLAbsPosEditor methods -------------- */ michael@0: /* -------- Implemented in nsHTMLAbsPosition.cpp --------- */ michael@0: NS_DECL_NSIHTMLABSPOSEDITOR michael@0: michael@0: /* ------------ nsIHTMLInlineTableEditor methods -------------- */ michael@0: /* ------- Implemented in nsHTMLInlineTableEditor.cpp --------- */ michael@0: NS_DECL_NSIHTMLINLINETABLEEDITOR michael@0: michael@0: /* ------------ nsIHTMLEditor methods -------------- */ michael@0: NS_IMETHOD CopyLastEditableChildStyles(nsIDOMNode *aPreviousBlock, nsIDOMNode *aNewBlock, michael@0: nsIDOMNode **aOutBrNode); michael@0: michael@0: NS_IMETHOD LoadHTML(const nsAString &aInputString); michael@0: michael@0: nsresult GetCSSBackgroundColorState(bool *aMixed, nsAString &aOutColor, michael@0: bool aBlockLevel); michael@0: NS_IMETHOD GetHTMLBackgroundColorState(bool *aMixed, nsAString &outColor); michael@0: michael@0: /* ------------ nsIEditorStyleSheets methods -------------- */ michael@0: michael@0: NS_IMETHOD AddStyleSheet(const nsAString & aURL); michael@0: NS_IMETHOD ReplaceStyleSheet(const nsAString& aURL); michael@0: NS_IMETHOD RemoveStyleSheet(const nsAString &aURL); michael@0: michael@0: NS_IMETHOD AddOverrideStyleSheet(const nsAString & aURL); michael@0: NS_IMETHOD ReplaceOverrideStyleSheet(const nsAString& aURL); michael@0: NS_IMETHOD RemoveOverrideStyleSheet(const nsAString &aURL); michael@0: michael@0: NS_IMETHOD EnableStyleSheet(const nsAString& aURL, bool aEnable); michael@0: michael@0: /* ------------ nsIEditorMailSupport methods -------------- */ michael@0: michael@0: NS_DECL_NSIEDITORMAILSUPPORT michael@0: michael@0: /* ------------ nsITableEditor methods -------------- */ michael@0: michael@0: NS_IMETHOD InsertTableCell(int32_t aNumber, bool aAfter); michael@0: NS_IMETHOD InsertTableColumn(int32_t aNumber, bool aAfter); michael@0: NS_IMETHOD InsertTableRow(int32_t aNumber, bool aAfter); michael@0: NS_IMETHOD DeleteTable(); michael@0: NS_IMETHOD DeleteTableCell(int32_t aNumber); michael@0: NS_IMETHOD DeleteTableCellContents(); michael@0: NS_IMETHOD DeleteTableColumn(int32_t aNumber); michael@0: NS_IMETHOD DeleteTableRow(int32_t aNumber); michael@0: NS_IMETHOD SelectTableCell(); michael@0: NS_IMETHOD SelectBlockOfCells(nsIDOMElement *aStartCell, nsIDOMElement *aEndCell); michael@0: NS_IMETHOD SelectTableRow(); michael@0: NS_IMETHOD SelectTableColumn(); michael@0: NS_IMETHOD SelectTable(); michael@0: NS_IMETHOD SelectAllTableCells(); michael@0: NS_IMETHOD SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElement **aNewCell); michael@0: NS_IMETHOD JoinTableCells(bool aMergeNonContiguousContents); michael@0: NS_IMETHOD SplitTableCell(); michael@0: NS_IMETHOD NormalizeTable(nsIDOMElement *aTable); michael@0: NS_IMETHOD GetCellIndexes(nsIDOMElement *aCell, michael@0: int32_t* aRowIndex, int32_t* aColIndex); michael@0: NS_IMETHOD GetTableSize(nsIDOMElement *aTable, michael@0: int32_t* aRowCount, int32_t* aColCount); michael@0: NS_IMETHOD GetCellAt(nsIDOMElement* aTable, int32_t aRowIndex, int32_t aColIndex, nsIDOMElement **aCell); michael@0: NS_IMETHOD GetCellDataAt(nsIDOMElement* aTable, michael@0: int32_t aRowIndex, int32_t aColIndex, michael@0: nsIDOMElement **aCell, michael@0: int32_t* aStartRowIndex, int32_t* aStartColIndex, michael@0: int32_t* aRowSpan, int32_t* aColSpan, michael@0: int32_t* aActualRowSpan, int32_t* aActualColSpan, michael@0: bool* aIsSelected); michael@0: NS_IMETHOD GetFirstRow(nsIDOMElement* aTableElement, nsIDOMNode** aRowNode); michael@0: NS_IMETHOD GetNextRow(nsIDOMNode* aCurrentRowNode, nsIDOMNode** aRowNode); michael@0: NS_IMETHOD GetLastCellInRow(nsIDOMNode* aRowNode, nsIDOMNode** aCellNode); michael@0: michael@0: NS_IMETHOD SetSelectionAfterTableEdit(nsIDOMElement* aTable, int32_t aRow, int32_t aCol, michael@0: int32_t aDirection, bool aSelected); michael@0: NS_IMETHOD GetSelectedOrParentTableElement(nsAString& aTagName, michael@0: int32_t *aSelectedCount, michael@0: nsIDOMElement** aTableElement); michael@0: NS_IMETHOD GetSelectedCellsType(nsIDOMElement *aElement, uint32_t *aSelectionType); michael@0: michael@0: nsresult GetCellFromRange(nsIDOMRange *aRange, nsIDOMElement **aCell); michael@0: michael@0: // Finds the first selected cell in first range of selection michael@0: // This is in the *order of selection*, not order in the table michael@0: // (i.e., each cell added to selection is added in another range michael@0: // in the selection's rangelist, independent of location in table) michael@0: // aRange is optional: returns the range around the cell michael@0: NS_IMETHOD GetFirstSelectedCell(nsIDOMRange **aRange, nsIDOMElement **aCell); michael@0: // Get next cell until no more are found. Always use GetFirstSelected cell first michael@0: // aRange is optional: returns the range around the cell michael@0: NS_IMETHOD GetNextSelectedCell(nsIDOMRange **aRange, nsIDOMElement **aCell); michael@0: michael@0: // Upper-left-most selected cell in table michael@0: NS_IMETHOD GetFirstSelectedCellInTable(int32_t *aRowIndex, int32_t *aColIndex, nsIDOMElement **aCell); michael@0: michael@0: /* miscellaneous */ michael@0: // This sets background on the appropriate container element (table, cell,) michael@0: // or calls into nsTextEditor to set the page background michael@0: NS_IMETHOD SetCSSBackgroundColor(const nsAString& aColor); michael@0: NS_IMETHOD SetHTMLBackgroundColor(const nsAString& aColor); michael@0: michael@0: /* ------------ Block methods moved from nsEditor -------------- */ michael@0: static already_AddRefed GetBlockNodeParent(nsIDOMNode *aNode); michael@0: michael@0: void IsNextCharInNodeWhitespace(nsIContent* aContent, michael@0: int32_t aOffset, michael@0: bool* outIsSpace, michael@0: bool* outIsNBSP, michael@0: nsIContent** outNode = nullptr, michael@0: int32_t* outOffset = 0); michael@0: void IsPrevCharInNodeWhitespace(nsIContent* aContent, michael@0: int32_t aOffset, michael@0: bool* outIsSpace, michael@0: bool* outIsNBSP, michael@0: nsIContent** outNode = nullptr, michael@0: int32_t* outOffset = 0); michael@0: michael@0: /* ------------ Overrides of nsEditor interface methods -------------- */ michael@0: michael@0: nsresult EndUpdateViewBatch(); michael@0: michael@0: /** prepare the editor for use */ michael@0: NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIContent *aRoot, michael@0: nsISelectionController *aSelCon, uint32_t aFlags, michael@0: const nsAString& aValue); michael@0: NS_IMETHOD PreDestroy(bool aDestroyingFrames); michael@0: michael@0: /** Internal, static version */ michael@0: // aElement must not be null. michael@0: static bool NodeIsBlockStatic(const mozilla::dom::Element* aElement); michael@0: static nsresult NodeIsBlockStatic(nsIDOMNode *aNode, bool *aIsBlock); michael@0: protected: michael@0: using nsEditor::IsBlockNode; michael@0: virtual bool IsBlockNode(nsINode *aNode); michael@0: michael@0: public: michael@0: NS_IMETHOD SetFlags(uint32_t aFlags); michael@0: michael@0: NS_IMETHOD Paste(int32_t aSelectionType); michael@0: NS_IMETHOD CanPaste(int32_t aSelectionType, bool *aCanPaste); michael@0: michael@0: NS_IMETHOD PasteTransferable(nsITransferable *aTransferable); michael@0: NS_IMETHOD CanPasteTransferable(nsITransferable *aTransferable, bool *aCanPaste); michael@0: michael@0: NS_IMETHOD DebugUnitTests(int32_t *outNumTests, int32_t *outNumTestsFailed); michael@0: michael@0: /** All editor operations which alter the doc should be prefaced michael@0: * with a call to StartOperation, naming the action and direction */ michael@0: NS_IMETHOD StartOperation(EditAction opID, michael@0: nsIEditor::EDirection aDirection); michael@0: michael@0: /** All editor operations which alter the doc should be followed michael@0: * with a call to EndOperation */ michael@0: NS_IMETHOD EndOperation(); michael@0: michael@0: /** returns true if aParentTag can contain a child of type aChildTag */ michael@0: virtual bool TagCanContainTag(nsIAtom* aParentTag, nsIAtom* aChildTag); michael@0: michael@0: /** returns true if aNode is a container */ michael@0: virtual bool IsContainer(nsIDOMNode *aNode); michael@0: michael@0: /** make the given selection span the entire document */ michael@0: NS_IMETHOD SelectEntireDocument(nsISelection *aSelection); michael@0: michael@0: NS_IMETHOD SetAttributeOrEquivalent(nsIDOMElement * aElement, michael@0: const nsAString & aAttribute, michael@0: const nsAString & aValue, michael@0: bool aSuppressTransaction); michael@0: NS_IMETHOD RemoveAttributeOrEquivalent(nsIDOMElement * aElement, michael@0: const nsAString & aAttribute, michael@0: bool aSuppressTransaction); michael@0: michael@0: /** join together any adjacent editable text nodes in the range */ michael@0: NS_IMETHOD CollapseAdjacentTextNodes(nsIDOMRange *aInRange); michael@0: michael@0: virtual bool AreNodesSameType(nsIContent* aNode1, nsIContent* aNode2) michael@0: MOZ_OVERRIDE; michael@0: michael@0: NS_IMETHOD DeleteSelectionImpl(EDirection aAction, michael@0: EStripWrappers aStripWrappers); michael@0: nsresult DeleteNode(nsINode* aNode); michael@0: NS_IMETHODIMP DeleteNode(nsIDOMNode * aNode); michael@0: NS_IMETHODIMP DeleteText(nsIDOMCharacterData *aTextNode, michael@0: uint32_t aOffset, michael@0: uint32_t aLength); michael@0: NS_IMETHOD InsertTextImpl(const nsAString& aStringToInsert, michael@0: nsCOMPtr *aInOutNode, michael@0: int32_t *aInOutOffset, michael@0: nsIDOMDocument *aDoc); michael@0: NS_IMETHOD_(bool) IsModifiableNode(nsIDOMNode *aNode); michael@0: virtual bool IsModifiableNode(nsINode *aNode); michael@0: michael@0: NS_IMETHOD GetIsSelectionEditable(bool* aIsSelectionEditable); michael@0: michael@0: NS_IMETHOD SelectAll(); michael@0: michael@0: NS_IMETHOD GetRootElement(nsIDOMElement **aRootElement); michael@0: michael@0: /* ------------ nsICSSLoaderObserver -------------- */ michael@0: NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet*aSheet, bool aWasAlternate, michael@0: nsresult aStatus); michael@0: michael@0: /* ------------ Utility Routines, not part of public API -------------- */ michael@0: NS_IMETHOD TypedText(const nsAString& aString, ETypingAction aAction); michael@0: nsresult InsertNodeAtPoint( nsIDOMNode *aNode, michael@0: nsCOMPtr *ioParent, michael@0: int32_t *ioOffset, michael@0: bool aNoEmptyNodes); michael@0: michael@0: // Use this to assure that selection is set after attribute nodes when michael@0: // trying to collapse selection at begining of a block node michael@0: // e.g., when setting at beginning of a table cell michael@0: // This will stop at a table, however, since we don't want to michael@0: // "drill down" into nested tables. michael@0: // aSelection is optional -- if null, we get current seletion michael@0: nsresult CollapseSelectionToDeepestNonTableFirstChild(nsISelection *aSelection, nsIDOMNode *aNode); michael@0: michael@0: /** michael@0: * aNode must be a non-null text node. michael@0: * outIsEmptyNode must be non-null. michael@0: */ michael@0: nsresult IsVisTextNode(nsIContent* aNode, michael@0: bool* outIsEmptyNode, michael@0: bool aSafeToAskFrames); michael@0: nsresult IsEmptyNode(nsIDOMNode *aNode, bool *outIsEmptyBlock, michael@0: bool aMozBRDoesntCount = false, michael@0: bool aListOrCellNotEmpty = false, michael@0: bool aSafeToAskFrames = false); michael@0: nsresult IsEmptyNode(nsINode* aNode, bool* outIsEmptyBlock, michael@0: bool aMozBRDoesntCount = false, michael@0: bool aListOrCellNotEmpty = false, michael@0: bool aSafeToAskFrames = false); michael@0: nsresult IsEmptyNodeImpl(nsINode* aNode, michael@0: bool *outIsEmptyBlock, michael@0: bool aMozBRDoesntCount, michael@0: bool aListOrCellNotEmpty, michael@0: bool aSafeToAskFrames, michael@0: bool *aSeenBR); michael@0: michael@0: // Returns TRUE if sheet was loaded, false if it wasn't michael@0: bool EnableExistingStyleSheet(const nsAString& aURL); michael@0: michael@0: // Dealing with the internal style sheet lists: michael@0: NS_IMETHOD GetStyleSheetForURL(const nsAString &aURL, michael@0: nsCSSStyleSheet **_retval); michael@0: NS_IMETHOD GetURLForStyleSheet(nsCSSStyleSheet *aStyleSheet, nsAString &aURL); michael@0: michael@0: // Add a url + known style sheet to the internal lists: michael@0: nsresult AddNewStyleSheetToList(const nsAString &aURL, michael@0: nsCSSStyleSheet *aStyleSheet); michael@0: michael@0: nsresult RemoveStyleSheetFromList(const nsAString &aURL); michael@0: michael@0: bool IsCSSEnabled() michael@0: { michael@0: // TODO: removal of mCSSAware and use only the presence of mHTMLCSSUtils michael@0: return mCSSAware && mHTMLCSSUtils && mHTMLCSSUtils->IsCSSPrefChecked(); michael@0: } michael@0: michael@0: static bool HasAttributes(mozilla::dom::Element* aElement) michael@0: { michael@0: MOZ_ASSERT(aElement); michael@0: uint32_t attrCount = aElement->GetAttrCount(); michael@0: return attrCount > 1 || michael@0: (1 == attrCount && !aElement->GetAttrNameAt(0)->Equals(nsGkAtoms::mozdirty)); michael@0: } michael@0: michael@0: protected: michael@0: michael@0: NS_IMETHOD InitRules(); michael@0: michael@0: // Create the event listeners for the editor to install michael@0: virtual void CreateEventListeners(); michael@0: michael@0: virtual nsresult InstallEventListeners(); michael@0: virtual void RemoveEventListeners(); michael@0: michael@0: bool ShouldReplaceRootElement(); michael@0: void ResetRootElementAndEventTarget(); michael@0: nsresult GetBodyElement(nsIDOMHTMLElement** aBody); michael@0: // Get the focused node of this editor. michael@0: // @return If the editor has focus, this returns the focused node. michael@0: // Otherwise, returns null. michael@0: already_AddRefed GetFocusedNode(); michael@0: michael@0: // Return TRUE if aElement is a table-related elemet and caret was set michael@0: bool SetCaretInTableCell(nsIDOMElement* aElement); michael@0: michael@0: // key event helpers michael@0: NS_IMETHOD TabInTable(bool inIsShift, bool *outHandled); michael@0: NS_IMETHOD CreateBR(nsIDOMNode *aNode, int32_t aOffset, michael@0: nsCOMPtr *outBRNode, nsIEditor::EDirection aSelect = nsIEditor::eNone); michael@0: michael@0: // Table Editing (implemented in nsTableEditor.cpp) michael@0: michael@0: // Table utilities michael@0: michael@0: // Insert a new cell after or before supplied aCell. michael@0: // Optional: If aNewCell supplied, returns the newly-created cell (addref'd, of course) michael@0: // This doesn't change or use the current selection michael@0: NS_IMETHOD InsertCell(nsIDOMElement *aCell, int32_t aRowSpan, int32_t aColSpan, michael@0: bool aAfter, bool aIsHeader, nsIDOMElement **aNewCell); michael@0: michael@0: // Helpers that don't touch the selection or do batch transactions michael@0: NS_IMETHOD DeleteRow(nsIDOMElement *aTable, int32_t aRowIndex); michael@0: NS_IMETHOD DeleteColumn(nsIDOMElement *aTable, int32_t aColIndex); michael@0: NS_IMETHOD DeleteCellContents(nsIDOMElement *aCell); michael@0: michael@0: // Move all contents from aCellToMerge into aTargetCell (append at end) michael@0: NS_IMETHOD MergeCells(nsCOMPtr aTargetCell, nsCOMPtr aCellToMerge, bool aDeleteCellToMerge); michael@0: michael@0: NS_IMETHOD DeleteTable2(nsIDOMElement *aTable, nsISelection *aSelection); michael@0: NS_IMETHOD SetColSpan(nsIDOMElement *aCell, int32_t aColSpan); michael@0: NS_IMETHOD SetRowSpan(nsIDOMElement *aCell, int32_t aRowSpan); michael@0: michael@0: // Helper used to get nsTableOuterFrame for a table. michael@0: nsTableOuterFrame* GetTableFrame(nsIDOMElement* aTable); michael@0: // Needed to do appropriate deleting when last cell or row is about to be deleted michael@0: // This doesn't count cells that don't start in the given row (are spanning from row above) michael@0: int32_t GetNumberOfCellsInRow(nsIDOMElement* aTable, int32_t rowIndex); michael@0: // Test if all cells in row or column at given index are selected michael@0: bool AllCellsInRowSelected(nsIDOMElement *aTable, int32_t aRowIndex, int32_t aNumberOfColumns); michael@0: bool AllCellsInColumnSelected(nsIDOMElement *aTable, int32_t aColIndex, int32_t aNumberOfRows); michael@0: michael@0: bool IsEmptyCell(mozilla::dom::Element* aCell); michael@0: michael@0: // Most insert methods need to get the same basic context data michael@0: // Any of the pointers may be null if you don't need that datum (for more efficiency) michael@0: // Input: *aCell is a known cell, michael@0: // if null, cell is obtained from the anchor node of the selection michael@0: // Returns NS_EDITOR_ELEMENT_NOT_FOUND if cell is not found even if aCell is null michael@0: NS_IMETHOD GetCellContext(nsISelection **aSelection, michael@0: nsIDOMElement **aTable, michael@0: nsIDOMElement **aCell, michael@0: nsIDOMNode **aCellParent, int32_t *aCellOffset, michael@0: int32_t *aRowIndex, int32_t *aColIndex); michael@0: michael@0: NS_IMETHOD GetCellSpansAt(nsIDOMElement* aTable, int32_t aRowIndex, int32_t aColIndex, michael@0: int32_t& aActualRowSpan, int32_t& aActualColSpan); michael@0: michael@0: NS_IMETHOD SplitCellIntoColumns(nsIDOMElement *aTable, int32_t aRowIndex, int32_t aColIndex, michael@0: int32_t aColSpanLeft, int32_t aColSpanRight, nsIDOMElement **aNewCell); michael@0: michael@0: NS_IMETHOD SplitCellIntoRows(nsIDOMElement *aTable, int32_t aRowIndex, int32_t aColIndex, michael@0: int32_t aRowSpanAbove, int32_t aRowSpanBelow, nsIDOMElement **aNewCell); michael@0: michael@0: nsresult CopyCellBackgroundColor(nsIDOMElement *destCell, nsIDOMElement *sourceCell); michael@0: michael@0: // Reduce rowspan/colspan when cells span into nonexistent rows/columns michael@0: NS_IMETHOD FixBadRowSpan(nsIDOMElement *aTable, int32_t aRowIndex, int32_t& aNewRowCount); michael@0: NS_IMETHOD FixBadColSpan(nsIDOMElement *aTable, int32_t aColIndex, int32_t& aNewColCount); michael@0: michael@0: // Fallback method: Call this after using ClearSelection() and you michael@0: // failed to set selection to some other content in the document michael@0: NS_IMETHOD SetSelectionAtDocumentStart(nsISelection *aSelection); michael@0: michael@0: // End of Table Editing utilities michael@0: michael@0: static nsCOMPtr GetEnclosingTable(nsIDOMNode *aNode); michael@0: michael@0: /** content-based query returns true if effects aNode michael@0: * If contains aNode, michael@0: * but also contains aNode and the second is michael@0: * more deeply nested than the first, then the first does not effect aNode. michael@0: * michael@0: * @param aNode The target of the query michael@0: * @param aProperty The property that we are querying for michael@0: * @param aAttribute The attribute of aProperty, example: color in michael@0: * May be null. michael@0: * @param aValue The value of aAttribute, example: blue in michael@0: * May be null. Ignored if aAttribute is null. michael@0: * @param aIsSet [OUT] true if effects aNode. michael@0: * @param outValue [OUT] the value of the attribute, if aIsSet is true michael@0: * michael@0: * The nsIContent variant returns aIsSet instead of using an out parameter. michael@0: */ michael@0: bool IsTextPropertySetByContent(nsIContent* aContent, michael@0: nsIAtom* aProperty, michael@0: const nsAString* aAttribute, michael@0: const nsAString* aValue, michael@0: nsAString* outValue = nullptr); michael@0: michael@0: void IsTextPropertySetByContent(nsIDOMNode* aNode, michael@0: nsIAtom* aProperty, michael@0: const nsAString* aAttribute, michael@0: const nsAString* aValue, michael@0: bool& aIsSet, michael@0: nsAString* outValue = nullptr); michael@0: michael@0: // Methods for handling plaintext quotations michael@0: NS_IMETHOD PasteAsPlaintextQuotation(int32_t aSelectionType); michael@0: michael@0: /** Insert a string as quoted text, michael@0: * replacing the selected text (if any). michael@0: * @param aQuotedText The string to insert. michael@0: * @param aAddCites Whether to prepend extra ">" to each line michael@0: * (usually true, unless those characters michael@0: * have already been added.) michael@0: * @return aNodeInserted The node spanning the insertion, if applicable. michael@0: * If aAddCites is false, this will be null. michael@0: */ michael@0: NS_IMETHOD InsertAsPlaintextQuotation(const nsAString & aQuotedText, michael@0: bool aAddCites, michael@0: nsIDOMNode **aNodeInserted); michael@0: michael@0: nsresult InsertObject(const char* aType, nsISupports* aObject, bool aIsSafe, michael@0: nsIDOMDocument *aSourceDoc, michael@0: nsIDOMNode *aDestinationNode, michael@0: int32_t aDestOffset, michael@0: bool aDoDeleteSelection); michael@0: michael@0: // factored methods for handling insertion of data from transferables (drag&drop or clipboard) michael@0: NS_IMETHOD PrepareTransferable(nsITransferable **transferable); michael@0: NS_IMETHOD PrepareHTMLTransferable(nsITransferable **transferable, bool havePrivFlavor); michael@0: NS_IMETHOD InsertFromTransferable(nsITransferable *transferable, michael@0: nsIDOMDocument *aSourceDoc, michael@0: const nsAString & aContextStr, michael@0: const nsAString & aInfoStr, michael@0: nsIDOMNode *aDestinationNode, michael@0: int32_t aDestinationOffset, michael@0: bool aDoDeleteSelection); michael@0: nsresult InsertFromDataTransfer(mozilla::dom::DataTransfer *aDataTransfer, michael@0: int32_t aIndex, michael@0: nsIDOMDocument *aSourceDoc, michael@0: nsIDOMNode *aDestinationNode, michael@0: int32_t aDestOffset, michael@0: bool aDoDeleteSelection); michael@0: bool HavePrivateHTMLFlavor( nsIClipboard *clipboard ); michael@0: nsresult ParseCFHTML(nsCString & aCfhtml, char16_t **aStuffToPaste, char16_t **aCfcontext); michael@0: nsresult DoContentFilterCallback(const nsAString &aFlavor, michael@0: nsIDOMDocument *aSourceDoc, michael@0: bool aWillDeleteSelection, michael@0: nsIDOMNode **aFragmentAsNode, michael@0: nsIDOMNode **aFragStartNode, michael@0: int32_t *aFragStartOffset, michael@0: nsIDOMNode **aFragEndNode, michael@0: int32_t *aFragEndOffset, michael@0: nsIDOMNode **aTargetNode, michael@0: int32_t *aTargetOffset, michael@0: bool *aDoContinue); michael@0: michael@0: bool IsInLink(nsIDOMNode *aNode, nsCOMPtr *outLink = nullptr); michael@0: nsresult StripFormattingNodes(nsIDOMNode *aNode, bool aOnlyList = false); michael@0: nsresult CreateDOMFragmentFromPaste(const nsAString & aInputString, michael@0: const nsAString & aContextStr, michael@0: const nsAString & aInfoStr, michael@0: nsCOMPtr *outFragNode, michael@0: nsCOMPtr *outStartNode, michael@0: nsCOMPtr *outEndNode, michael@0: int32_t *outStartOffset, michael@0: int32_t *outEndOffset, michael@0: bool aTrustedInput); michael@0: nsresult ParseFragment(const nsAString & aStr, nsIAtom* aContextLocalName, michael@0: nsIDocument* aTargetDoc, michael@0: nsCOMPtr *outNode, michael@0: bool aTrustedInput); michael@0: nsresult CreateListOfNodesToPaste(nsIDOMNode *aFragmentAsNode, michael@0: nsCOMArray& outNodeList, michael@0: nsIDOMNode *aStartNode, michael@0: int32_t aStartOffset, michael@0: nsIDOMNode *aEndNode, michael@0: int32_t aEndOffset); michael@0: nsresult CreateTagStack(nsTArray &aTagStack, michael@0: nsIDOMNode *aNode); michael@0: nsresult GetListAndTableParents( bool aEnd, michael@0: nsCOMArray& aListOfNodes, michael@0: nsCOMArray& outArray); michael@0: nsresult DiscoverPartialListsAndTables(nsCOMArray& aPasteNodes, michael@0: nsCOMArray& aListsAndTables, michael@0: int32_t *outHighWaterMark); michael@0: nsresult ScanForListAndTableStructure(bool aEnd, michael@0: nsCOMArray& aNodes, michael@0: nsIDOMNode *aListOrTable, michael@0: nsCOMPtr *outReplaceNode); michael@0: nsresult ReplaceOrphanedStructure( bool aEnd, michael@0: nsCOMArray& aNodeArray, michael@0: nsCOMArray& aListAndTableArray, michael@0: int32_t aHighWaterMark); michael@0: nsIDOMNode* GetArrayEndpoint(bool aEnd, nsCOMArray& aNodeArray); michael@0: michael@0: /* small utility routine to test if a break node is visible to user */ michael@0: bool IsVisBreak(nsIDOMNode *aNode); michael@0: michael@0: /* utility routine to possibly adjust the insertion position when michael@0: inserting a block level element */ michael@0: void NormalizeEOLInsertPosition(nsIDOMNode *firstNodeToInsert, michael@0: nsCOMPtr *insertParentNode, michael@0: int32_t *insertOffset); michael@0: michael@0: /* small utility routine to test the eEditorReadonly bit */ michael@0: bool IsModifiable(); michael@0: michael@0: /* helpers for block transformations */ michael@0: nsresult MakeDefinitionItem(const nsAString & aItemType); michael@0: nsresult InsertBasicBlock(const nsAString & aBlockType); michael@0: michael@0: /* increase/decrease the font size of selection */ michael@0: nsresult RelativeFontChange( int32_t aSizeChange); michael@0: michael@0: /* helper routines for font size changing */ michael@0: nsresult RelativeFontChangeOnTextNode( int32_t aSizeChange, michael@0: nsIDOMCharacterData *aTextNode, michael@0: int32_t aStartOffset, michael@0: int32_t aEndOffset); michael@0: nsresult RelativeFontChangeOnNode(int32_t aSizeChange, nsINode* aNode); michael@0: nsresult RelativeFontChangeHelper(int32_t aSizeChange, nsINode* aNode); michael@0: michael@0: /* helper routines for inline style */ michael@0: nsresult SetInlinePropertyOnTextNode( nsIDOMCharacterData *aTextNode, michael@0: int32_t aStartOffset, michael@0: int32_t aEndOffset, michael@0: nsIAtom *aProperty, michael@0: const nsAString *aAttribute, michael@0: const nsAString *aValue); michael@0: nsresult SetInlinePropertyOnNode( nsIDOMNode *aNode, michael@0: nsIAtom *aProperty, michael@0: const nsAString *aAttribute, michael@0: const nsAString *aValue); michael@0: nsresult SetInlinePropertyOnNode(nsIContent* aNode, michael@0: nsIAtom* aProperty, michael@0: const nsAString* aAttribute, michael@0: const nsAString* aValue); michael@0: michael@0: nsresult PromoteInlineRange(nsIDOMRange *inRange); michael@0: nsresult PromoteRangeIfStartsOrEndsInNamedAnchor(nsIDOMRange *inRange); michael@0: nsresult SplitStyleAboveRange(nsIDOMRange *aRange, michael@0: nsIAtom *aProperty, michael@0: const nsAString *aAttribute); michael@0: nsresult SplitStyleAbovePoint(nsCOMPtr *aNode, michael@0: int32_t *aOffset, michael@0: nsIAtom *aProperty, michael@0: const nsAString *aAttribute, michael@0: nsCOMPtr *outLeftNode = nullptr, michael@0: nsCOMPtr *outRightNode = nullptr); michael@0: nsresult ApplyDefaultProperties(); michael@0: nsresult RemoveStyleInside(nsIDOMNode *aNode, michael@0: nsIAtom *aProperty, michael@0: const nsAString *aAttribute, michael@0: const bool aChildrenOnly = false); michael@0: nsresult RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAString *aAttribute); michael@0: michael@0: bool NodeIsProperty(nsIDOMNode *aNode); michael@0: bool HasAttr(nsIDOMNode *aNode, const nsAString *aAttribute); michael@0: bool IsAtFrontOfNode(nsIDOMNode *aNode, int32_t aOffset); michael@0: bool IsAtEndOfNode(nsIDOMNode *aNode, int32_t aOffset); michael@0: bool IsOnlyAttribute(nsIDOMNode *aElement, const nsAString *aAttribute); michael@0: bool IsOnlyAttribute(const nsIContent* aElement, const nsAString& aAttribute); michael@0: michael@0: nsresult RemoveBlockContainer(nsIDOMNode *inNode); michael@0: michael@0: nsIContent* GetPriorHTMLSibling(nsINode* aNode); michael@0: nsresult GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr *outNode); michael@0: nsIContent* GetPriorHTMLSibling(nsINode* aParent, int32_t aOffset); michael@0: nsresult GetPriorHTMLSibling(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr *outNode); michael@0: michael@0: nsIContent* GetNextHTMLSibling(nsINode* aNode); michael@0: nsresult GetNextHTMLSibling(nsIDOMNode *inNode, nsCOMPtr *outNode); michael@0: nsIContent* GetNextHTMLSibling(nsINode* aParent, int32_t aOffset); michael@0: nsresult GetNextHTMLSibling(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr *outNode); michael@0: michael@0: nsIContent* GetPriorHTMLNode(nsINode* aNode, bool aNoBlockCrossing = false); michael@0: nsresult GetPriorHTMLNode(nsIDOMNode *inNode, nsCOMPtr *outNode, bool bNoBlockCrossing = false); michael@0: nsIContent* GetPriorHTMLNode(nsINode* aParent, int32_t aOffset, michael@0: bool aNoBlockCrossing = false); michael@0: nsresult GetPriorHTMLNode(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr *outNode, bool bNoBlockCrossing = false); michael@0: michael@0: nsIContent* GetNextHTMLNode(nsINode* aNode, bool aNoBlockCrossing = false); michael@0: nsresult GetNextHTMLNode(nsIDOMNode *inNode, nsCOMPtr *outNode, bool bNoBlockCrossing = false); michael@0: nsIContent* GetNextHTMLNode(nsINode* aParent, int32_t aOffset, michael@0: bool aNoBlockCrossing = false); michael@0: nsresult GetNextHTMLNode(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr *outNode, bool bNoBlockCrossing = false); michael@0: michael@0: nsresult IsFirstEditableChild( nsIDOMNode *aNode, bool *aOutIsFirst); michael@0: nsresult IsLastEditableChild( nsIDOMNode *aNode, bool *aOutIsLast); michael@0: nsresult GetFirstEditableChild( nsIDOMNode *aNode, nsCOMPtr *aOutFirstChild); michael@0: nsresult GetLastEditableChild( nsIDOMNode *aNode, nsCOMPtr *aOutLastChild); michael@0: michael@0: nsresult GetFirstEditableLeaf( nsIDOMNode *aNode, nsCOMPtr *aOutFirstLeaf); michael@0: nsresult GetLastEditableLeaf( nsIDOMNode *aNode, nsCOMPtr *aOutLastLeaf); michael@0: michael@0: nsresult GetInlinePropertyBase(nsIAtom *aProperty, michael@0: const nsAString *aAttribute, michael@0: const nsAString *aValue, michael@0: bool *aFirst, michael@0: bool *aAny, michael@0: bool *aAll, michael@0: nsAString *outValue, michael@0: bool aCheckDefaults = true); michael@0: bool HasStyleOrIdOrClass(mozilla::dom::Element* aElement); michael@0: nsresult RemoveElementIfNoStyleOrIdOrClass(nsIDOMNode* aElement); michael@0: michael@0: // Whether the outer window of the DOM event target has focus or not. michael@0: bool OurWindowHasFocus(); michael@0: michael@0: // This function is used to insert a string of HTML input optionally with some michael@0: // context information into the editable field. The HTML input either comes michael@0: // from a transferable object created as part of a drop/paste operation, or from michael@0: // the InsertHTML method. We may want the HTML input to be sanitized (for example, michael@0: // if it's coming from a transferable object), in which case aTrustedInput should michael@0: // be set to false, otherwise, the caller should set it to true, which means that michael@0: // the HTML will be inserted in the DOM verbatim. michael@0: // michael@0: // aClearStyle should be set to false if you want the paste to be affected by michael@0: // local style (e.g., for the insertHTML command). michael@0: nsresult DoInsertHTMLWithContext(const nsAString& aInputString, michael@0: const nsAString& aContextStr, michael@0: const nsAString& aInfoStr, michael@0: const nsAString& aFlavor, michael@0: nsIDOMDocument* aSourceDoc, michael@0: nsIDOMNode* aDestNode, michael@0: int32_t aDestOffset, michael@0: bool aDeleteSelection, michael@0: bool aTrustedInput, michael@0: bool aClearStyle = true); michael@0: michael@0: nsresult ClearStyle(nsCOMPtr* aNode, int32_t* aOffset, michael@0: nsIAtom* aProperty, const nsAString* aAttribute); michael@0: michael@0: // Data members michael@0: protected: michael@0: michael@0: nsCOMArray mContentFilters; michael@0: michael@0: nsRefPtr mTypeInState; michael@0: michael@0: bool mCRInParagraphCreatesParagraph; michael@0: michael@0: bool mCSSAware; michael@0: nsAutoPtr mHTMLCSSUtils; michael@0: michael@0: // Used by GetFirstSelectedCell and GetNextSelectedCell michael@0: int32_t mSelectedCellIndex; michael@0: michael@0: nsString mLastStyleSheetURL; michael@0: nsString mLastOverrideStyleSheetURL; michael@0: michael@0: // Maintain a list of associated style sheets and their urls. michael@0: nsTArray mStyleSheetURLs; michael@0: nsTArray > mStyleSheets; michael@0: michael@0: // an array for holding default style settings michael@0: nsTArray mDefaultStyles; michael@0: michael@0: protected: michael@0: michael@0: /* ANONYMOUS UTILS */ michael@0: void RemoveListenerAndDeleteRef(const nsAString& aEvent, michael@0: nsIDOMEventListener* aListener, michael@0: bool aUseCapture, michael@0: nsIDOMElement* aElement, michael@0: nsIContent* aParentContent, michael@0: nsIPresShell* aShell); michael@0: void DeleteRefToAnonymousNode(nsIDOMElement* aElement, michael@0: nsIContent * aParentContent, michael@0: nsIPresShell* aShell); michael@0: michael@0: nsresult ShowResizersInner(nsIDOMElement *aResizedElement); michael@0: michael@0: // Returns the offset of an element's frame to its absolute containing block. michael@0: nsresult GetElementOrigin(nsIDOMElement * aElement, int32_t & aX, int32_t & aY); michael@0: nsresult GetPositionAndDimensions(nsIDOMElement * aElement, michael@0: int32_t & aX, int32_t & aY, michael@0: int32_t & aW, int32_t & aH, michael@0: int32_t & aBorderLeft, michael@0: int32_t & aBorderTop, michael@0: int32_t & aMarginLeft, michael@0: int32_t & aMarginTop); michael@0: michael@0: /* PACKED BOOLEANS FOR RESIZING, ABSOLUTE POSITIONING AND */ michael@0: /* INLINE TABLE EDITING */ michael@0: michael@0: // resizing michael@0: bool mIsObjectResizingEnabled; michael@0: bool mIsResizing; michael@0: bool mPreserveRatio; michael@0: bool mResizedObjectIsAnImage; michael@0: michael@0: // absolute positioning michael@0: bool mIsAbsolutelyPositioningEnabled; michael@0: bool mResizedObjectIsAbsolutelyPositioned; michael@0: michael@0: bool mGrabberClicked; michael@0: bool mIsMoving; michael@0: michael@0: bool mSnapToGridEnabled; michael@0: michael@0: // inline table editing michael@0: bool mIsInlineTableEditingEnabled; michael@0: michael@0: /* RESIZING */ michael@0: michael@0: nsCOMPtr mTopLeftHandle; michael@0: nsCOMPtr mTopHandle; michael@0: nsCOMPtr mTopRightHandle; michael@0: nsCOMPtr mLeftHandle; michael@0: nsCOMPtr mRightHandle; michael@0: nsCOMPtr mBottomLeftHandle; michael@0: nsCOMPtr mBottomHandle; michael@0: nsCOMPtr mBottomRightHandle; michael@0: michael@0: nsCOMPtr mActivatedHandle; michael@0: michael@0: nsCOMPtr mResizingShadow; michael@0: nsCOMPtr mResizingInfo; michael@0: michael@0: nsCOMPtr mResizedObject; michael@0: michael@0: nsCOMPtr mMouseMotionListenerP; michael@0: nsCOMPtr mSelectionListenerP; michael@0: nsCOMPtr mResizeEventListenerP; michael@0: michael@0: nsCOMArray objectResizeEventListeners; michael@0: michael@0: int32_t mOriginalX; michael@0: int32_t mOriginalY; michael@0: michael@0: int32_t mResizedObjectX; michael@0: int32_t mResizedObjectY; michael@0: int32_t mResizedObjectWidth; michael@0: int32_t mResizedObjectHeight; michael@0: michael@0: int32_t mResizedObjectMarginLeft; michael@0: int32_t mResizedObjectMarginTop; michael@0: int32_t mResizedObjectBorderLeft; michael@0: int32_t mResizedObjectBorderTop; michael@0: michael@0: int32_t mXIncrementFactor; michael@0: int32_t mYIncrementFactor; michael@0: int32_t mWidthIncrementFactor; michael@0: int32_t mHeightIncrementFactor; michael@0: michael@0: int8_t mInfoXIncrement; michael@0: int8_t mInfoYIncrement; michael@0: michael@0: nsresult SetAllResizersPosition(); michael@0: michael@0: nsresult CreateResizer(nsIDOMElement ** aReturn, int16_t aLocation, nsIDOMNode * aParentNode); michael@0: void SetAnonymousElementPosition(int32_t aX, int32_t aY, nsIDOMElement *aResizer); michael@0: michael@0: nsresult CreateShadow(nsIDOMElement ** aReturn, nsIDOMNode * aParentNode, michael@0: nsIDOMElement * aOriginalObject); michael@0: nsresult SetShadowPosition(nsIDOMElement * aShadow, michael@0: nsIDOMElement * aOriginalObject, michael@0: int32_t aOriginalObjectX, michael@0: int32_t aOriginalObjectY); michael@0: michael@0: nsresult CreateResizingInfo(nsIDOMElement ** aReturn, nsIDOMNode * aParentNode); michael@0: nsresult SetResizingInfoPosition(int32_t aX, int32_t aY, michael@0: int32_t aW, int32_t aH); michael@0: michael@0: int32_t GetNewResizingIncrement(int32_t aX, int32_t aY, int32_t aID); michael@0: nsresult StartResizing(nsIDOMElement * aHandle); michael@0: int32_t GetNewResizingX(int32_t aX, int32_t aY); michael@0: int32_t GetNewResizingY(int32_t aX, int32_t aY); michael@0: int32_t GetNewResizingWidth(int32_t aX, int32_t aY); michael@0: int32_t GetNewResizingHeight(int32_t aX, int32_t aY); michael@0: void HideShadowAndInfo(); michael@0: void SetFinalSize(int32_t aX, int32_t aY); michael@0: void DeleteRefToAnonymousNode(nsIDOMNode * aNode); michael@0: void SetResizeIncrements(int32_t aX, int32_t aY, int32_t aW, int32_t aH, bool aPreserveRatio); michael@0: void HideAnonymousEditingUIs(); michael@0: michael@0: /* ABSOLUTE POSITIONING */ michael@0: michael@0: int32_t mPositionedObjectX; michael@0: int32_t mPositionedObjectY; michael@0: int32_t mPositionedObjectWidth; michael@0: int32_t mPositionedObjectHeight; michael@0: michael@0: int32_t mPositionedObjectMarginLeft; michael@0: int32_t mPositionedObjectMarginTop; michael@0: int32_t mPositionedObjectBorderLeft; michael@0: int32_t mPositionedObjectBorderTop; michael@0: michael@0: nsCOMPtr mAbsolutelyPositionedObject; michael@0: nsCOMPtr mGrabber; michael@0: nsCOMPtr mPositioningShadow; michael@0: michael@0: int32_t mGridSize; michael@0: michael@0: nsresult CreateGrabber(nsIDOMNode * aParentNode, nsIDOMElement ** aReturn); michael@0: nsresult StartMoving(nsIDOMElement * aHandle); michael@0: nsresult SetFinalPosition(int32_t aX, int32_t aY); michael@0: void AddPositioningOffset(int32_t & aX, int32_t & aY); michael@0: void SnapToGrid(int32_t & newX, int32_t & newY); michael@0: nsresult GrabberClicked(); michael@0: nsresult EndMoving(); michael@0: nsresult CheckPositionedElementBGandFG(nsIDOMElement * aElement, michael@0: nsAString & aReturn); michael@0: michael@0: /* INLINE TABLE EDITING */ michael@0: michael@0: nsCOMPtr mInlineEditedCell; michael@0: michael@0: nsCOMPtr mAddColumnBeforeButton; michael@0: nsCOMPtr mRemoveColumnButton; michael@0: nsCOMPtr mAddColumnAfterButton; michael@0: michael@0: nsCOMPtr mAddRowBeforeButton; michael@0: nsCOMPtr mRemoveRowButton; michael@0: nsCOMPtr mAddRowAfterButton; michael@0: michael@0: void AddMouseClickListener(nsIDOMElement * aElement); michael@0: void RemoveMouseClickListener(nsIDOMElement * aElement); michael@0: michael@0: nsCOMPtr mLinkHandler; michael@0: michael@0: public: michael@0: michael@0: // friends michael@0: friend class nsHTMLEditRules; michael@0: friend class nsTextEditRules; michael@0: friend class nsWSRunObject; michael@0: friend class nsHTMLEditorEventListener; michael@0: michael@0: private: michael@0: // Helpers michael@0: bool IsSimpleModifiableNode(nsIContent* aContent, michael@0: nsIAtom* aProperty, michael@0: const nsAString* aAttribute, michael@0: const nsAString* aValue); michael@0: nsresult SetInlinePropertyOnNodeImpl(nsIContent* aNode, michael@0: nsIAtom* aProperty, michael@0: const nsAString* aAttribute, michael@0: const nsAString* aValue); michael@0: typedef enum { eInserted, eAppended } InsertedOrAppended; michael@0: void DoContentInserted(nsIDocument* aDocument, nsIContent* aContainer, michael@0: nsIContent* aChild, int32_t aIndexInContainer, michael@0: InsertedOrAppended aInsertedOrAppended); michael@0: }; michael@0: #endif //nsHTMLEditor_h__ michael@0: